Get the path to an image with ImageCache preset in Drupal 7, its very easy
Use this function image_style_url($style_name, $path)
See Example
$image_uri = $node->field_image['und'][0]['uri']; // will be public://my_image
$style = 'image_style'; //this you will get from admin -> image styles options
$final_img_url = image_style_url($style, $image_uri);
//Will result like http://mydomain.com/sites/default/files/styles/<img_style>/public/pages/banner1.jp
Did this post help you?
Tutsplanet brings in-depth and easy tutorials to understand even for beginners. This takes a considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.
Leave a Reply