• Thea

    (@dorothy1508)


    Is it possible to set my own default placeholder for posts that don’t have a featured image?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Yes,

    you have to replace thumb-medium.png and thumb-small.png files in hueman|img folder.

    Best regards

    There should be a filter for this, so it can be set on a child theme without messing up with the original theme.

    There isn’t a filter because the call is part of the theme code, not WP. This should help get you started:
    1. Create a folder in your child theme: /img
    2. Add your image to that folder and name it “thumb-medium.png”
    3. Copy the content.php file from the parent theme to your child theme.
    4. Find this block of code near the top of content.php:

    <?php if ( has_post_thumbnail() ): ?>
    	<?php the_post_thumbnail('thumb-medium'); ?>
    <?php elseif ( ot_get_option('placeholder') != 'off' ): ?>
    	<img src="<?php echo get_template_directory_uri(); ?>/img/thumb-medium.png" alt="<?php the_title(); ?>" />
    <?php endif; ?>

    Change the <img> tag to get the file from your child theme:

    <img src="<?php echo get_stylesheet_directory_uri(); ?>/img/thumb-medium.png" alt="<?php the_title();

    You can do the same thing with content-featured and content-standard, although content-standard uses “thumb-standard.png”. For the sidebar widgets, alx-posts.php uses “thumb-medium.png” and alx-tabs.php uses “thumb-small.png”.

    Hi there bdbrown,

    Yes, I already thought of that approach but I think it’s just too much to do for a very simple thing.

    There’s no reason whatsoever why the theme can’t have his own filters ??
    I’ll try to do it when I have some spare time and commit it to github.

    Cheers.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Use own image for placeholder’ is closed to new replies.