The website has only one thumbnail size 375x211. I want to show this size thumbnail image at site homepage so that when I copy this image it only copies in 375x211 size, not in full image size which is 728x410

The following code will produce an img tag with the content.php present:

<?php $defalt_arg =array('class' => "img-responsive"); ?>
            <?php if(has_post_thumbnail()): ?>
        <a  href="<?php the_permalink(); ?>">
            <?php the_post_thumbnail('', $defalt_arg); ?>


Custom size in funtion.php

add_theme_support( 'post-thumbnails' ); 

        add_image_size( 'img-responsive', 375, 211, true );

Here is the image source code:

<img src="/uploads/2018/09/Transportation-Access.jpg" class="img-responsive wp-post-image" srcset="uploads/2018/09/Transportation-Access.jpg 728w, /uploads/2018/09/Transportation-Access-375x211.jpg 375w" sizes="(max-width: 728px) 100vw, 728px" width="728" height="410">

Please help me understand what I am doing wrong!

  • Please Regenerate Thumbnails. than after check – Dharmishtha Patel Sep 6 '18 at 11:54
  • I have regenerated and uploaded the image again. But nothing works. I think the problem is in src="/uploads/2018/09/Transportation-Access.jpg" which is not showing like /uploads/2018/09/Transportation-Access-375x211.jpg – rudyards Sep 7 '18 at 5:22
  • <?php the_post_thumbnail($defalt_arg); ?> please try to this and also check in uplods/2018/09/ your size image – Dharmishtha Patel Sep 7 '18 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.