I'm using a view template to override how a field is displayed.

The field happens to be an attached image to the node.

I notice in the view it's configured to display the thumbnail - when overriding, how do I get the thumbnail?

(I'm using entity_metadata_wrapper )


So based on the suggetions below I need to use image_style_url - how do I get the path to pass to it?

ie, how do I complete this code

$node = node_load($row->{$field->field_alias});
$wrapper = entity_metadata_wrapper('node', $survey_node); 

// Field is called field_image

$path = ???

$thumbnail_url = image_style_url('thumbnail', $path)

print "<img src='" & $thumbnail_url & "'>"

You need to use function image_style_url($style_name, $path) to obtain proper path in Drupal 7.20 and later. $path is a path to an original file. Preferably output normal path, and make it a thumbnail in proper .tpl.php file.

If you need to do it in place that does not accept php functions and cannot alter it in template, you can consider disabling itok token. To do so, add following line to your settings.php

$conf['image_allow_insecure_derivatives'] = TRUE;

Then you can simply add styles/thumbnail/public/ like Kevin says, and use path like example.com/sites/default/files/styles/thumbnail/public/myimage.jpg to get thumbnail of example.com/sites/default/files/myimage.jpg.


In your default/files you will see a styles folder containing the same structure and same name for the files. Those are all your image styles inclusive thumbs.

so default/files/myimage.jpg has thumbnail default/files/styles/thumbnail/public/myimage.jpg

  • You forgot itok security token.
    – Mołot
    Aug 2 '13 at 7:18

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.