• Hello Everyone,

    I would like to force all my post images (around 500 posts and probably 5000 images) that are using “original size” images to use “large thumbnail” instead.

    Any idea of a script that could achieve this?

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The only way is to parse through the content of all posts, searching for img tags. You can determine the size originally inserted from one of the assigned classes. When “size-full” class is found, replace the current image tag with a new one generated by script to use the new size, but keeping other attributes like justification and link target. There are several possible configurations your script may run into, it needs to be able to deal with any of them. For example, images with captions are inserted with a shortcode that contains a width argument that should match that of the image.

    To avoid timeout errors, the script may need to work in batches. Processed posts could have a tag or other marker added so the script can query for the next batch of posts from those without such a tag. When no posts are returned by such a query, all the posts have been processed. If need be, the tag can be removed.

    Removal may be another batch process, though the batches can be bigger because the processing is much simpler. There’s an SQL query that will do this all at once very quickly, but handling raw SQL processing of taxonomies is tricky. If you go this route, use a post meta field as the marker, these are much easier and safer to remove by SQL.

Viewing 1 replies (of 1 total)
  • The topic ‘Change all post images to use “large” thumbnail size’ is closed to new replies.