I imported a load of content from wordpress, and I am using the teaser thumbnail module. I need to effectively click 'edit' and 'save' on all my content so that any images create thumbnails on save automatically. Is there any way to do this.


The image style files won't be generated when you save the node, only when the style URLs are requested for the first time.

You can generate the styles manually but I think it'll take some custom code. Without knowing more about your setup it's tricky but the following should get you started:

// Get the ids of nodes you want to generate styles for.
$nids = db_query('SELECT nid FROM {node} WHERE type = :type', array(':type' => 'my_type'))->fetchCol();

// Load the node objects
$nodes = node_load_multiple($nids);

// Setup a list of fields to generate styles for
$fields = array('field_image', 'field_image2');

// Setup a list of styles to generate
$styles = array('thumbnail', 'small');

foreach ($nodes as $node) {
  foreach ($fields as $field_name) {
    // Extract the fields items to get at the file ids.
    $image_items = field_get_items('node', $node, $field_name);

    foreach ($image_items as $image_item) {
      // Load the file
      $file = file_load($image_item['fid']);

      foreach ($styles as $style_name) {
        // Get a URI for the image style.
        $derivative_uri = image_style_path($style_name, $file->uri);

        // Create the derivative
        image_style_create_derivative($style_name, $file->uri, $derivative_uri);  
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.