Drupalese for links?
nimzie - October 15, 2008 - 16:06
$filelist[] = '<a href= "' . base_path().$file->filename.'" target="_blank"><img width="100" src="' . base_path().$file->filename . '" /></a>';
I've hacked together this link, however since I'm not using the l function, it's affecting how Drupal is handling other things down the road... like I need the file name from this link at one point... Not sure how to get that either.
If anyone can help me convert this link to Drupalese, that would be awesome... The end result of the link code is:
<a href= "/lifetrek/files/images/import/IMG_5792.JPG" target="_blank"><img width="100" src="/lifetrek/files/images/import/IMG_5792.JPG" /></a>
Cheers~!
Adam

Use theme_image() followed by l()
You can use the theme_image() function to get the image HTML followed by the link function l() to make the image a link.
The following should work if $file->filepath is relative. You will need to change the sixth parameter of the link function to TRUE if you use an absolute path.
<?php
$image = theme_image($file->filepath, 'imagealt', 'imagetitle', array('target' => '_blank'), TRUE);
//print ($image);
print l($image, $file->filepath, NULL, NULL, NULL, FALSE, TRUE);
?>
Check the parameter details for both function at the links above so you can see what all the NULLs, FALSEs etc refer to.