Hey there,

By using

print theme('imagecache', 'preset_name', $image[filepath]); 

We get returned an img tag with the src set to the imagecache generated image.

Is there a way to return just the src, as plain text (not as part of an img tag)?

For example I just want to be able to access "/files/imagecache/presetname/imagename.jpg" (but it needs to know to generate the image if it hasn't already, like the theme function does).

Thanks a lot.

Comments

mason@thecodingdesigner.com’s picture

I don't know how to do exactly what you're saying, but you can use php to parse the imagecache output to get the url string.

$image = YOURIMAGETAG;  //like: <img src="http://domain/sites/default/files/imagecache/Home_Feature/flexpromo/images/home-feature.jpg" alt="" title=""  width="626" height="261" />
$src_start = strpos($image, 'src="') + 5;
$src_end = strpos($image, '"', $src_start);
$src = substr($image, $src_start, $src_end - $src_start);
jrefano’s picture

Status: Active » Closed (fixed)

works great, thanks!

jrefano’s picture

i have since found the correct way to do this, which im not sure why i didnt realize before. imagecache_create_url() returns the path to the image w/o the image tag.

volocuga’s picture

Had the same issue, look at this http://drupal.org/node/659610