Plugin Author
Ajay
(@ajay)
The plugin uses WP’s inbuilt function for the srcset: Please see this: https://github.com/WebberZone/contextual-related-posts/blob/5f7000cc1c83918636076493d346805f7c95b3a5/includes/media.php#L335
It uses wp_get_attachment_metadata to get the meta data for the image including the sizes and it looks like the image size of 50 seems to being returned for this image.
Is there a way you can check that?
Hi, sorry it took so long. When I call wp_get_attachment_metadata I get:
Array ( [width] => 1024 [height] => 679 [file] => 2014/04/mieso-paleo-smak.jpg [sizes] => Array ( [thumbnail] => Array ( [file] => mieso-paleo-smak-150×150.jpg [width] => 150 [height] => 150 [mime-type] => image/jpeg [ewww_image_optimizer] => Zmniejszono o 7.6% (692,0 B ) – Poprzednio zoptymalizowano [cw_image_optimizer] => No savings ) [medium] => Array ( [file] => mieso-paleo-smak-500×332.jpg [width] => 500 [height] => 332 [mime-type] => image/jpeg [ewww_image_optimizer] => Zmniejszono o 7.3% (3,1 kB) – Poprzednio zoptymalizowano [cw_image_optimizer] => No savings ) [large] => Array ( [file] => mieso-paleo-smak-500×332.jpg [width] => 500 [height] => 332 [mime-type] => image/jpeg [ewww_image_optimizer] => Brak zysku [cw_image_optimizer] => No savings ) [post-thumbnail] => Array ( [file] => mieso-paleo-smak-672×372.jpg [width] => 672 [height] => 372 [mime-type] => image/jpeg [ewww_image_optimizer] => Zmniejszono o 6.8% (4,5 kB) – Poprzednio zoptymalizowano [cw_image_optimizer] => No savings ) [twentyfourteen-full-width] => Array ( [file] => mieso-paleo-smak-1024×576.jpg [width] => 1024 [height] => 576 [mime-type] => image/jpeg [ewww_image_optimizer] => Zmniejszono o 6.0% (9,5 kB) – Poprzednio zoptymalizowano [cw_image_optimizer] => No savings ) [crp_thumbnail] => Array ( [file] => mieso-paleo-smak-150×150.jpg [width] => 150 [height] => 150 [mime-type] => image/jpeg [ewww_image_optimizer] => Brak zysku [cw_image_optimizer] => No savings ) [tptn_thumbnail] => Array ( [file] => mieso-paleo-smak-50×50.jpg [width] => 50 [height] => 50 [mime-type] => image/jpeg [ewww_image_optimizer] => Zmniejszono o 18.5% (390,0 B ) – Poprzednio zoptymalizowano [cw_image_optimizer] => No savings ) ) [image_meta] => Array ( [aperture] => 0 [credit] => [camera] => [caption] => [created_timestamp] => 0 [copyright] => [focal_length] => 0 [iso] => 0 [shutter_speed] => 0 [title] => [orientation] => 0 ) [ewww_image_optimizer] => Reduced by 3.6% (5,3 kB) – Poprzednio zoptymalizowano [cw_image_optimizer] => No savings )
So shitload of rubbish parameters. I don’t have anymore the sizes 50×50, but I guess the metadata is still there.
Any idea how I can clean up this rubbish without coding it? Is there a nice plugin for it? 🙂
OK, in the meantime I wrote some dirty code that cleaned up all that mess from my metadata and most of the non-existing images links are gone. Some persist and I will try to get rid of them. Thank you for your support!
Plugin Author
Ajay
(@ajay)
@grzegorzjanoszka
Sorry for the delayed response. What did you do exactly to clean up the meta data. Might be useful for my site as well.
Hi,
Something dirty like that:
$args = array('post_type'=>'attachment','numberposts'=>-1);
$attachments = get_posts($args);
if($attachments){
foreach($attachments as $attachment){
$image_meta = wp_get_attachment_metadata( $attachment->ID );
# wywala się, jak nie ma takich rzeczy ustawionych
unset ($image_meta['ewww_image_optimizer']);
unset ($image_meta['cw_image_optimizer']);
unset ($image_meta['sizes']['large']);
unset ($image_meta['sizes']['1536x1536']);
unset ($image_meta['sizes']['post-thumbnail']);
unset ($image_meta['sizes']['crp_thumbnail']);
unset ($image_meta['sizes']['tptn_thumbnail']);
unset ($image_meta['sizes']['twentyfourteen-full-width']);
unset ($image_meta['sizes']['thumbnail']['ewww_image_optimizer']);
unset ($image_meta['sizes']['thumbnail']['cw_image_optimizer']);
unset ($image_meta['sizes']['medium']['ewww_image_optimizer']);
unset ($image_meta['sizes']['medium']['cw_image_optimizer']);
wp_update_attachment_metadata( $attachment->ID, $image_meta);
}
}
For me it worked.
Plugin Author
Ajay
(@ajay)
Thank you. This is pretty useful. Can be customised when I figure out my various image sizes that I need to clean. Lots of theme changs means I have a tonne of that for sure.
-
This reply was modified 1 month, 4 weeks ago by
Ajay.