I read tons of solutions how to render an image in a
PHPtemplate where I have the whole node in
$content, however I don't get how to render it using a
$node object, including the given image style etc.
So I got all the code working and can access the node title for example via:
How do I generate the proper
HTML for this node (in this example the machine tag is
This line does not work, it gives me a 404 for the image URL:
<img src="<?php print image_style_url('slideshow', $node->field_slideshow_image['und']['uri']); ?>" />
however, it contains at least the name of the actual image…
I found out that I have to force an image creation if there was none before, so now it works using:
$image_uri = $node->field_slideshow_image['und']['uri']; // or any public://my_image $style = 'slideshow'; $derivative_uri = image_style_path($style, $image_uri); $success = file_exists($derivative_uri) || image_style_create_derivative($style, $image_uri, $derivative_uri); $new_image_url = file_create_url($derivative_uri); echo $new_image_url."<br /><br />"; echo "<img class=\"slideshow_image\" src=\"".$new_image_url."\" />";
However, the image style "slideshow" does not get applied! I tried it with the default "thumbnail" and that one works well.