I'm struggling with a piece of code in my views field template.
A short overview of the situation:
- Node product has a field with filename for an image
- Images are added with filezilla in default/files/products
What is the best way to implement image styles on these images. My code:
<?php
print theme('image_style', array('style_name' => 'product_overzicht', 'path' => $img_url));
?>
Where $img_url is just a simple variable, like: img_filename.jpg
This doesn't work because the folder of that image style is empty. I know the easy way is to use an image field on my product node but this can't be done here. I use a excel import for all products and the image filename is a column in that excel file. Images are all together in a folder.
Does anybody know a way do this or a good workaround. CSS markup is not good because the image size needs to be as low as possible in the view but on de node details page I would like to show the entire image.
Any tips or advice is welcome!
$img_url
is incomplete. You say the images are uploaded to sites/default/files/products so$img_url
should be'products/filename.jpg'
i.e. the path relative to sites/default/files. If the variables supplied to the theme function are correct, Drupal should automatically generate the folder contents during the page request.