I just added a new WordPress thumbnail size using add_image_size
call, but now all the photos I already uploaded are not of the correct size. If I request them, all I get is the original image with width
and height
attributes correctly set.
How can I force the creation of that thumb, saving the data to the database as well, given an attachment ID?
Please note I want to do a simple admin operation or execute code from a theme file.
I don’t know if there’s an operation to do this from the admin, but I can execute this code from a theme file:
that recreates all of the thumb sizes at once (don’t know if the already created ones are done as well, but it’s a one time code execution).
You must replace “www.example.com” with your URL and $attachment with an actual attachment post structure, retrieved with
get_post
or similar.This is bug #13947. Instead of
the_post_thumbnail()
use this code in your theme until the bug is fixed: