AMILO 36 Posted July 22, 2014 Report Share Posted July 22, 2014 Здравствуйте! Собственно сабж: есть сайт на WordPress, много добавлено новостей, миниатюры не создавались - по скольку тогда их не надо было создавать. Теперь установили новый шаблон с закосом под Bootstrap и в нем не отображаются картинки (то есть тема настроена на вывод картинок из миниатюры). Вопрос: есть ли какой-нибудь плагин, который поможет сделать вывод вместо миниатюры - первую картинку поста (типа замену "post-thumbnails" на обычную картинку из новости) Если вы спросите: А чё не создадите миниатюры и весь вопрос решен? - Ответ: там 1000 новостей - я запарюсь. Link to post Share on other sites
Hromoff 16 Posted July 23, 2014 Report Share Posted July 23, 2014 Попробуй вот этот - он как раз берет первую картинку. Может заработает с твоей темой ВП. http://www.sanisoft.com/blog/2010/04/19/wordpress-plugin-automatic-post-thumbnail/ AMILO 1 Link to post Share on other sites
AMILO 36 Posted July 23, 2014 Author Report Share Posted July 23, 2014 Попробуй вот этот - он как раз берет первую картинку. Может заработает с твоей темой ВП. http://www.sanisoft.com/blog/2010/04/19/wordpress-plugin-automatic-post-thumbnail/ Привет! Пробовал, этот плагин не работает. Полоске бежит - а результата никакого нету. Link to post Share on other sites
Модератор files 2838 Posted July 23, 2014 Модератор Report Share Posted July 23, 2014 Создать миниатюры не проблема. Ставите плагин generate-post-thumbnails В настройках появляется пункт Генерация миниатюр В настройках выбираете «1» (брать для миниатюры первую картинку из записи) и жмем на кнопку «Сгенерировать миниатюры». AMILO 1 Link to post Share on other sites
AMILO 36 Posted July 23, 2014 Author Report Share Posted July 23, 2014 Создать миниатюры не проблема. Ставите плагин generate-post-thumbnails В настройках появляется пункт Генерация миниатюр В настройках выбираете «1» (брать для миниатюры первую картинку из записи) и жмем на кнопку «Сгенерировать миниатюры». Попробовал. Вот кусок из Live-лога: Post: 1. No image found in the post... Post: 5. Remote server does not return image... Post: 6. Remote server does not return image... Post: 7. Remote server does not return image... Post: 8. Remote server does not return image... Post: 9. Remote server does not return image... Post: 10. Post has featured image already. Skipping... Post: 11. Remote server does not return image... Post: 12. Post has featured image already. Skipping... Post: 13. Remote server does not return image... Post: 14. Remote server does not return image... Post: 15. Post has featured image already. Skipping... Post: 16. No image found in the post... Post: 17. Remote server does not return image... Post: 18. Post has featured image already. Skipping... Post: 19. Post has featured image already. Skipping... Post: 20. Post has featured image already. Skipping... Post: 21. Post has featured image already. Skipping... Post: 22. Post has featured image already. Skipping... Post: 23. Post has featured image already. Skipping... Post: 24. Post has featured image already. Skipping... Post: 25. Post has featured image already. Skipping... Post: 26. Post has featured image already. Skipping... Post: 27. Remote server does not return image... Post: 28. Remote server does not return image... Post: 29. Post has featured image already. Skipping... Post: 30. Remote server does not return image... Post: 31. Post has featured image already. Skipping... Post: 32. Post has featured image already. Skipping... Post: 33. Post has featured image already. Skipping... Post: 34. Post has featured image already. Skipping... Post: 35. Remote server does not return image... Post: 36. Post has featured image already. Skipping... Post: 37. Remote server does not return image... Post: 38. Remote server does not return image... Post: 39. Post has featured image already. Skipping... Post: 40. Remote server does not return image... Post: 41. Remote server does not return image... Post: 42. Post has featured image already. Skipping... Post: 43. Post has featured image already. Skipping... Post: 44. Post has featured image already. Skipping... Post: 45. Post has featured image already. Skipping... Post: 46. Post has featured image already. Skipping... Post: 47. Post has featured image already. Skipping... Post: 48. Remote server does not return image... Post: 49. Post has featured image already. Skipping... Post: 50. Post has featured image already. Skipping... Post: 51. No image found in the post... Post: 52. Post has featured image already. Skipping... Post: 53. Post has featured image already. Skipping... Post: 54. Post has featured image already. Skipping... Post: 55. Remote server does not return image... Post: 56. Remote server does not return image... Post: 57. Remote server does not return image... Post: 58. Remote server does not return image... Post: 59. Post has featured image already. Skipping... Post: 60. Remote server does not return image... Post: 61. Remote server does not return image... Post: 62. Post has featured image already. Skipping... Post: 63. Post has featured image already. Skipping... Post: 64. Remote server does not return image... Post: 65. Post has featured image already. Skipping... Post: 66. Post has featured image already. Skipping... Post: 67. Remote server does not return image... Post: 68. Remote server does not return image... Post: 69. Post has featured image already. Skipping... Post: 70. Post has featured image already. Skipping... Post: 71. Post has featured image already. Skipping... Post: 72. Post has featured image already. Skipping... Post: 73. No image found in the post... Post: 74. Post has featured image already. Skipping... Post: 75. Post has featured image already. Skipping... Post: 76. Post has featured image already. Skipping... Post: 77. Post has featured image already. Skipping... Post: 78. Post has featured image already. Skipping... Post: 79. Post has featured image already. Skipping... Post: 80. Post has featured image already. Skipping... Post: 81. Post has featured image already. Skipping... Post: 82. Remote server does not return image... Post: 83. Post has featured image already. Skipping... Post: 84. Post has featured image already. Skipping... Post: 85. Post has featured image already. Skipping... Post: 86. Post has featured image already. Skipping... Post: 87. Post has featured image already. Skipping... Post: 88. Remote server does not return image... Post: 89. Post has featured image already. Skipping... Post: 90. Remote server does not return image... Post: 91. Post has featured image already. Skipping... Post: 92. Post has featured image already. Skipping... Post: 93. Remote server does not return image... Post: 94. Post has featured image already. Skipping... Link to post Share on other sites
Irakez 97 Posted July 23, 2014 Report Share Posted July 23, 2014 Хорошо что я подумал заранее. Я делаю проще. Без плагинов. Первую картинку из поста в Пэйнте уменьшаю до 150 пикселей с пропорциями и к названию приписываю -mini. И всё. Но у Вас, да. Ситуация посложнее будет Тут, я думаю, только плагин нужен, к сожалению. Link to post Share on other sites
AMILO 36 Posted July 23, 2014 Author Report Share Posted July 23, 2014 А интересно, можно как-нибудь в коде заменить: типа код миниатюры на код первой картинки из поста (ну и ей прописать width и height), чтобы просто в шаблоне вместо превьюшки была тупо картинка из поста? Link to post Share on other sites
Irakez 97 Posted July 23, 2014 Report Share Posted July 23, 2014 А интересно, можно как-нибудь в коде заменить: типа код миниатюры на код первой картинки из поста (ну и ей прописать width и height), чтобы просто в шаблоне вместо превьюшки была тупо картинка из поста? Это идея, кстати. Нужно копаться в дизайне. Но наверное врядли width и height. Скорее всего size или как-то по другому. Всё от темы зависит же. Link to post Share on other sites
AMILO 36 Posted July 23, 2014 Author Report Share Posted July 23, 2014 Это идея, кстати. Нужно копаться в дизайне. Но наверное врядли width и height. Скорее всего size или как-то по другому. Всё от темы зависит же. А в WordPress'e теги изображений как-то описываются? Ну к примеру у движка DLE тег первой картинки из полной новости {image-1}. А в WordPress'e как? Link to post Share on other sites
Модератор files 2838 Posted July 24, 2014 Модератор Report Share Posted July 24, 2014 А в WordPress'e теги изображений как-то описываются? Ну к примеру у движка DLE тег первой картинки из полной новости {image-1}. А в WordPress'e как? Только через функцию. Делаем все следующим образом: Открываем functions.php в папке с темой, в конце прописываем функцию: function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = "/images/default.jpg"; } return $first_img; } Эта функция ищет изображение в посте (вернет урл на картинку), если его нет, то выводится дефолтная картинка - /images/default.jpg Вызов функции в шаблоне: <?php echo catch_that_image() ?> Удачи! AMILO 1 Link to post Share on other sites
AMILO 36 Posted July 24, 2014 Author Report Share Posted July 24, 2014 Только через функцию. Делаем все следующим образом: Открываем functions.php в папке с темой, в конце прописываем функцию: function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = "/images/default.jpg"; } return $first_img; } Эта функция ищет изображение в посте (вернет урл на картинку), если его нет, то выводится дефолтная картинка - /images/default.jpg Вызов функции в шаблоне: <?php echo catch_that_image() ?> Удачи! В functions.php код вставил. А в какой файл в шаблоне надо вставить код: <?php echo catch_that_image() ?> чтобы вместо миниатюр - отображались картинки. И как его правильно описать, на сколько я понял, то этот код только выводит путь, типа как в моем случае: (/images/kvadrat.jpg) Естественно его можно описать как: <img src="<?php echo catch_that_image() ?>"> для того, чтобы просто отображалась картинка. А как ее внедрить так, чтобы она была точь в точь вместе с параметрами только вместо миниатюры? Где надо копать? Работаю с шаблоном WordPress: Pictorico - он доступен в поиске тем WordPress. На всякий случай код из index.php: <?php /** * The main template file. * * This is the most generic template file in a WordPress theme * and one of the two required files for a theme (the other being style.css). * It is used to display a page when nothing more specific matches a query. * E.g., it puts together the home page when no home.php file exists. * Learn more: http://codex.wordpress.org/Template_Hierarchy * * @package Pictorico */ get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php if ( have_posts() ) : ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php /* Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'content', 'home' ); ?> <?php endwhile; ?> <?php pictorico_paging_nav(); ?> <?php else : ?> <?php get_template_part( 'content', 'none' ); ?> <?php endif; ?> </main><!-- #main --> </div><!-- #primary --> <?php get_footer(); ?> А также из page.php: <?php /** * The template for displaying all pages. * * This is the template that displays all pages by default. * Please note that this is the WordPress construct of pages * and that other 'pages' on your WordPress site will use a * different template. * * @package Pictorico */ get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', 'page' ); ?> <?php // If comments are open or we have at least one comment, load up the comment template if ( comments_open() || '0' != get_comments_number() ) : comments_template(); endif; ?> <?php endwhile; // end of the loop. ?> </main><!-- #main --> </div><!-- #primary --> <?php get_footer(); ?> Link to post Share on other sites
Olezhko 9 Posted August 10, 2014 Report Share Posted August 10, 2014 могу сделать. делал даже чтобы картинки были адекватного размера. стучите в скайп olegavp Link to post Share on other sites
Crack_key 48 Posted August 10, 2014 Report Share Posted August 10, 2014 Плагины есть в офф.репозитории. Также можно через стиль в css прописать. Link to post Share on other sites
DiXakMan 24 Posted August 11, 2014 Report Share Posted August 11, 2014 Могу помочь в решении Вашей проблемы. Очень много опыта в решении проблем конкретно для WordPress. 250 руб. - 1 час. Консультация бесплатно + аудит юзабилити сайта. Контакты: Skype: diman07858 ICQ: 557221885 Гарантии: персональный аттестат BL 110+ Link to post Share on other sites
AMILO 36 Posted August 11, 2014 Author Report Share Posted August 11, 2014 Могу помочь в решении Вашей проблемы. Очень много опыта в решении проблем конкретно для WordPress. 250 руб. - 1 час. Консультация бесплатно + аудит юзабилити сайта. Контакты: Skype: diman07858 ICQ: 557221885 Гарантии: персональный аттестат BL 110+ Воланда на вас нету Здесь кажись тематический форум, где люди делятся опытом, а не предлагают свои услуги. Link to post Share on other sites
DiXakMan 24 Posted August 11, 2014 Report Share Posted August 11, 2014 Воланда на вас нету Здесь кажись тематический форум, где люди делятся опытом, а не предлагают свои услуги. Мало ли устанете Я готов даже поделиться опытом если вдруг Вы захотите воспользоваться моими услугами, как это сделать, с радостью расскажу. Link to post Share on other sites
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now