Thanks in advance for your help.

In Drupal 5, I was able use <img src="/files/imagecache/970px/<?php print $field_picture[0]['filepath']; ?>" /> because ['filepath'] contained files/myimage.jpg creating the correct path src="/files/imagecache/970px/files/myimage.jpg".

In Drupal 6, I seem to be stuck with too much data in the ['filepath'] array:sites/default/files/images/2010/01/17/myimage.jpg

Is there a way to remove sites/default/files/ from the beginning of the array and end up with just images/2010/01/17/myimage.jpg ?

Thanks again,
Scott

Comments

vm’s picture

In D5 the files folder was in the root. In D6 it is not by default.

Sc0tt’s picture

Can anyone recommend an alternative method?

I tried using

<?php
print theme('imagecache', '970px', $node->field_picture[0]['filepath']);
?>

but it didn't work.

Thanks again,
Scott

Sc0tt’s picture

The code in my previous post does work with images contained within the node; but it wont work with a loaded node based on a CCK node reference. Here is what I am trying:

<?php
//if using stock item then load the node
if ($field_inline_1_stock) { 
$ref_node = node_load($node->field_inline_1_stock[0]['nid']);
//if referenced image filename exists
if ($ref_node->field_stock_picture[0]['filename']) { 
//display the image using imagecache
print theme('imagecache', '720px_wide', $node->field_stock_picture[0]['filepath']);
?>

Any suggestions?

Thank you very much,
Scott

anou’s picture

After hours of searching a way to print, in php, the filepath to an imagecache image preset, I did this :

<?php
$exp = '^sites\/default\/files';

//my cck field is called 'img'
$newpath = ereg_replace($exp,'',$node->field_img[0]['filepath']);

//then add path to the imagecache folder desired
$finalpath = '/sites/default/files/imagecache/nameofyourpreset'.$newpath;
?>

et voilà.
Hope that will help.

David THOMAS
http://www.smol.org