Every now and then I work on a project were the image styles are missing and usually not regenerating. This usually occurs when moving a site from one hosting provider to another due to missing files and or purging image styles.
In this case, I was moving a Drupal 7 project to Pantheon. This is when I found missing images and I was trying to regenerate them.
A couple of good modules for managing image styles are:
After installing these modules and working on regenerating image styles, nothing was happening. Well actually more images were disappearing, due to not regenerating new image styles and purging the old files.
While I worked with these image styles a bit longer I realized they couldn't be regenerated. Re-uploading and saving the content that these image styles were related to also did not regenerate the missing image styles.
The Imageinfo Cache module also showed that the images styles I was trying to regenerate and work with were not used by Drupal. After a further review, I discovered the images from these image styles were pulled into templates without any way to regenerate them. So once the image styles were on the server there wasn't a way to regenerate them.
I ended up updating the theme template variables before passing the variables to the template. Instead of using a file name with a hardcoded URL I ended up using the image_style_url function:
$image_url = image_style_url($style, $file_name);
When calling image_style_url function, this function gave Drupal an opportunity to regenerate the image styles on the fly, if the images style images were not on the server.
More about the function: image_style_url:
Returns the URL for an image derivative given a style and image path.
$style_name: The name of the style to be used with this image.
$path: The path to the image.
The absolute URL where a style image can be downloaded, suitable for use in an <img> tag. Requesting the URL will cause the image to be created.
Source for image_style_url: https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_style_url/7.x