Closed (fixed)
Project:
ImageCache
Version:
6.x-2.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
14 Mar 2009 at 04:27 UTC
Updated:
23 Sep 2009 at 20:59 UTC
Using the following code:
print theme('imagecache', 'preset1', $field_pictures[$image_index]['filepath']);
... I can get an image with an applied preset directly ouput to the page.
What if I need only the path to that image, not the full themed output? What function can I call to get something like this:
http://www.myserver.com/sites/default/files/imagecache/preset1/1/c2.jpg
Comments
Comment #1
walker2238 commentedNot sure if theres a better way but try adding your URL and apply the file name. so maybe try this...
Comment #2
kirilius commentedThanks, I figured something like that but I was hoping to be able to use an API function in order to stay independent on the actual physical paths.
Comment #3
walker2238 commentedForgive me is I don't understand you request very well. but you could also do...
Is that what you mean? If not I'm afraid I can't help you.
Comment #4
kirilius commentedMuch like when you do the following functional call:
... you just pass the preset name as a parameter and don't care how the underlying file structure is organized...
I would like to call a function that hives me the physical path for an image derivative without the need to concatenate string literals myself.
Comment #5
walker2238 commentedOkay I understand you now. I was actually looking to do the same thing awhile back and I couldn't find a solution. If you have any luck please let me know.
Comment #6
otsuarez commentedSome sort of "workaround" would be using something like this:
where field_img is the cck field where the image is stored and product-image is the imagecache preset. For some reason, filename and filepath were different (maybe having to deal with me uploading more than one time the same image, the filepath had an extra _0 at the end of the filename).
Still, an api based function would be the ideal solution.
Comment #7
drewish commentedimagecache_create_path() or imagecache_create_url() in imagecache.module.
Comment #8
kirilius commentedThanks ;-)
Comment #10
NoRandom commentedJust in case it helps to somebody. Using this method in Drupal 5 I had problems.
At first I had output link with this code:
$output = '< a href="/' . $imagecache_full . '" rel="lightbox" title="' . $node->title . '.">' . $imagecache_miniature . ''
Note the starting slash. This lead to double the base site in the url like h ttp://mysite.com//h ttp://mysite.com/files/foo/foo...
Removing the slash the generated url is ok.
Kind regards.