I am using ACF to add image fields to some posts and returning the Image ID so that I can use wp_get_attachment_image to get responsive images. I have defined 960 and 1920 as the medium and large images sizes (widths) in the admin and added a couple of custom sizes: add_image_size( 'category-plate', 572, 9999 ); add_image_size( 'place-story-photo', 1316, 9999 );

My code is pretty straight-forward:

<?php $hero_image = get_field( 'hero_image' ); ?> <?php if ( $hero_image ) { ?> <?php echo wp_get_attachment_image( $hero_image, 'large' ); ?> <?php } ?>

But what I get for output is unexpected as there are many more image references than I have defined. Plus – most of them don’t actually exist in the uploads folder so often the page renders with a broken link icon. Here’s the output:

<img width="1920" height="360" src="http://br.test/wp-content/uploads/landing-activities-1920x360.jpg" class="attachment-large size-large" alt="Find activities along the byway" srcset="http://br.test/wp-content/uploads/landing-activities-1920x360.jpg 1920w, http://br.test/wp-content/uploads/landing-activities-960x180.jpg 960w, http://br.test/wp-content/uploads/landing-activities-768x144.jpg 768w, http://br.test/wp-content/uploads/landing-activities-572x107.jpg 572w, http://br.test/wp-content/uploads/landing-activities-1316x247.jpg 1316w, http://br.test/wp-content/uploads/landing-activities-540x101.jpg 540w, http://br.test/wp-content/uploads/landing-activities-286x54.jpg 286w, http://br.test/wp-content/uploads/landing-activities-658x123.jpg 658w, http://br.test/wp-content/uploads/landing-activities-800x150.jpg 800w, http://br.test/wp-content/uploads/landing-activities-1600x300.jpg 1600w, http://br.test/wp-content/uploads/landing-activities-340x64.jpg 340w, http://br.test/wp-content/uploads/landing-activities-420x79.jpg 420w, http://br.test/wp-content/uploads/landing-activities-600x113.jpg 600w, http://br.test/wp-content/uploads/landing-activities-760x143.jpg 760w, http://br.test/wp-content/uploads/landing-activities-780x146.jpg 780w, http://br.test/wp-content/uploads/landing-activities-880x165.jpg 880w, http://br.test/wp-content/uploads/landing-activities-1080x203.jpg 1080w, http://br.test/wp-content/uploads/landing-activities-1260x236.jpg 1260w, http://br.test/wp-content/uploads/landing-activities-1400x263.jpg 1400w" sizes="(max-width: 1920px) 100vw, 1920px">

I did have some other custom images sizes previously and tried remove_image_size to remove them, but that did not seem to have any effect.

Thanks for looking!

  • It has been some time since I used it but this plugin was very useful when adding or removing thumbnail sizes. Suggest working on a dev or staging copy of your site before testing on production. wordpress.org/plugins/regenerate-thumbnails – jdm2112 May 14 '18 at 16:47
  • Thanks. Yes, I should have mentioned that I have regenerated the images – and I do get only those that I have defined in the admin and in the functions.php file. Where the other 14 image links are coming from is a mystery… – Al Avery May 14 '18 at 16:57
  • The 2nd note in this section sheds a little light: developer.wordpress.org/reference/functions/add_image_size/…. You may also find these extra sizes are registered in one or more plugins. This should show you what is active and valid: wordpress.stackexchange.com/questions/16143/… – jdm2112 May 14 '18 at 17:10
  • When I list the additional image sizes I only get the two I have defined in my functions.php file. BUT, I just took a look at the wp_postmeta table and it looks like the extra image values might be coming from there. Here's a screenshot: link The question is, how do I update the wp_postmeta table so that it reflects the current image sizes? – Al Avery May 14 '18 at 19:20
  • If I individually replace the media using the Replace Media plugin, the images sizes correct themselves. I've only got 50 images or so, so doing that is not terrible, just time-consuming. It would be great to know why that meta data is so sticky…Thanks! – Al Avery May 14 '18 at 20:14

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.