Error message

The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.

Drupal 7 - Theme Image Style Example

Category: 

If you have an image style specified in Drupal 7 and you'd like to programmatically render an image thumb nail with that image style, try something like this:

$image = theme(
  'image_style',
  array(
    'path' => 'public://my_example_image.jpg',
    'style_name' => 'my_custom_image_style',
    'alt' => 'Alternate Text',
    'title' => 'Title Text',
  )
);
print $image;

This would work if you had an image style specified at admin/config/media/image-styles that was called 'my_custom_image_style'.

Comments

Thank's!

Thanks for sharing.

Add new comment