-
AuthorPosts
-
July 20, 2016 at 2:25 pm #662967
Hi there,
How can I change the default thumbnail image, which is displayed when no image is uploaded?
Thank you in advance and all the best,
Andreas
July 20, 2016 at 3:32 pm #663011Hey andreasobermeier,
Would you mind providing a precise link to your site, showing the elements in question? We need to be able to inspect them in order to help :)
Do you want to remove it completely?
Best regards,
AndyJuly 20, 2016 at 3:36 pm #663020Hey Andi,
sure, no problem.
No, I don’t want to remove it, but replace it with a custom image.
So the aim is the following: If a user creates a blog post and doesn’t upload a post image there should be a custom image displayed at the left side.
Best,
Andreas
July 21, 2016 at 11:28 am #663293Hi,
just use WordPress’ default Featured Image option.
Best regards,
AndyJuly 21, 2016 at 11:39 am #663299Hi Andy,
for this I would have to add a plugin, right?
Best regards,
Andreas
July 21, 2016 at 12:36 pm #663354Hi,
no, just use WordPress’ default Features Image option: http://www.wpbeginner.com/beginners-guide/how-to-add-featured-image-or-post-thumbnails-in-wordpress/
Best regards,
AndyJuly 30, 2016 at 2:38 pm #666824Hi there once again,
I couldn’ really solve that problem. I don’t want to use a plugin.
The content in the link from you describes how to use the thumbnail function of WordPress.
But I want to achieve the following:
When creating a new post and e.g. I forget to upload a thumbnail I want a default fallback thmbnail picture to be displayed (right now it’s a pen).I found this code, but don’t know where to place it, however.
<?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } else { ?> <img src="<?php bloginfo('template_directory'); ?>/images/default-thumb-img.png" alt="<?php the_title(); ?>" /> <?php } ?>
I hope you can help me with this one.
Thank you for your support and best regards,
Andreas
- This reply was modified 8 years, 3 months ago by andreasobermeier.
August 4, 2016 at 6:37 am #668404Hi,
Please add this in the functions.php file instead:
add_filter('avf_loop_index_blog_meta', 'avf_loop_index_blog_meta_mod', 10, 1); function avf_loop_index_blog_meta_mod($output) { $link = get_permalink(); $fallback = strpos($output, 'iconfont'); if ($fallback <= 200) { $output = "<a href='{$link}' class='small-preview' title='Advanced Post'><img src='FALLBACK IMAGE URL HERE'/></a>"; } return $output; }
Adjust the placeholder image url.
Best regards,
IsmaelAugust 4, 2016 at 3:12 pm #668611Hi Ismael,
thank you it’s perfect. You can close this of course.
Best wishes,
Andreas -
AuthorPosts
- The topic ‘Change default thumbnail image’ is closed to new replies.