Hi there,
I've slightly modified this plugin to fit my needs and I thought I should post my findings here for anyone that may have a similar problem aswell as for Stramm to have a look at it and maybe give me some pointers.
Before I post my code, let me talk you through my scenario:
- I only wish to display the url of the intermediate picture below it. (that's no problem at all by editing the codebase.php)
Once I had done that I noticed something:
-
If an image was too small to have an intermediate image created, the link wouldn't work!So here is my updated solution. I check if the intermediate image exists and if it doesn't it shows the image path to the original image (which is the fullsize_url). On top of that I put the code into a text field to avoid lengthy urls to break the page layout and added a little javascript to autohighlight the whole code once clicked so it can easily be copied to the clipboard.
I've added info to the code to it's simple to see what I've done. I hope this comes in helpful to some users.
Here is the codebase.php code:
<?php
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
// Add a filter
$thisplugin->add_filter('file_data','imglnk_add_data');
function imglnk_add_data($pic_data){ //$pic_data
global $CONFIG;
//you can grab intermediate and thumb URL to just comment out what you need and add the var below
// this is the fullsize image url
$fullsize_url = get_pic_url($pic_data);
// this is the thumbnail URL
// Edited out as not needed in standard
//$thumb_url = get_pic_url($pic_data, 'thumb');
// this is the intermediate picture
$normal_url = get_pic_url($pic_data, 'normal');
//
// start check for small images (if no intermediate created)
// if intermediate pic exists, show it
if (file_exists($normal_url)) {
$pic_data['html'] = $pic_data['html'].'<div align="center"><form name="links"><br /><b>To post this image in forums, please click and copy the code below:</b><br /><br /><input name="normal" class="textinput" value="[IMG]'.$CONFIG['ecards_more_pic_target'].$normal_url.'[/IMG]" size="80" type="text" onClick="javascript:this.form.normal.focus();this.form.normal.select();"><br /></form></div>';
} else { // if the image was too small for intermediate picture to have been created, show original full url
$pic_data['html'] = $pic_data['html'].'<div align="center"><form name="links"><br /><b>To post this image in forums, please click and copy the code below:</b><br /><br /><input name="normal" class="textinput" value="[IMG]'.$CONFIG['ecards_more_pic_target'].$fullsize_url.'[/IMG]" size="80" type="text" onClick="javascript:this.form.normal.focus();this.form.normal.select();"><br /></form></div>';
}
// end check
//
return $pic_data; //page output
}
?>
Many thanks to Stramm for his work on all these great plugins.