In Drupal 7 there is a theme('image_style') which is similar to theme('imagecache')
<?php
$hero_image = array(
'style_name' => 'case_study_teaser',
'path' => $image['uri'],
'width' => '',
'height' => '',
'alt' => $image['alt'],
'title' => $image['title'],
);
print theme
('image_style',$hero_image);
?>
There is also a very handy little function in Drupal 7.
<?php
$img_url = 'public://myimagefolder/imgfilename.jpg'; // the orig image uri
$style = 'thumbnail'; // or any other custom image style you've created via /admin/config/media/image-styles
?>
<img src="<?php print image_style_url($style, $img_url) ?>>
The image_style_url() function takes the URI and converts into the relevant URL for the image style provided. Note, you need to use public:// rather than the base url of your site for this function to work.
The great thing is that if the image hasn't yet been created then Drupal does it automatically!
Post new comment