Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Linking txp:thumbnail to full size img (w/o popup)
Could <txp:thumbnail /> have a link attribute added? Or could poplink=0 create a plain link to the full size image? The one core hack I’ve applied multiple times is auto-linking thumbnails. It makes sense, in my mind at least, to link the thumbnail to its corresponding, full size image.
Offline
Re: Linking txp:thumbnail to full size img (w/o popup)
Here’s another idea. I think since Textpattern is moving in a more semantic direction with the removal of style and align attributes, for example, poplink should be removed from <txp:thumbnail /> and replaced with link. It should be the responsibility of the user to create popup links through JavaScript rather than onclick event handlers.
Offline
#3 2007-11-03 06:59:19
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Linking txp:thumbnail to full size img (w/o popup)
Sounds fine to me.
Offline
Re: Linking txp:thumbnail to full size img (w/o popup)
Here’s the patched section based off r2679 of taghandlers.php. I added if ($link || $poplink) for backward compatibility. I’ve also made <txp:thumbnail /> automatically link to the full-size image, which does break compatability for users with a non-linking thumbnail, but I don’t think it’s too big of a deal.
Will link make it into 4.0.6?
// -------------------------------------------------------------
function thumbnail($atts)
{
global $img_dir;
extract(lAtts(array(
'align' => '', // remove soon
'class' => '',
'escape' => '',
'html_id' => '',
'id' => '',
'name' => '',
'link' => '1',
'poplink' => '', // rm
'style' => '', // rm
'wraptag' => ''
), $atts));
if ($name)
{
$name = doSlash($name);
$rs = safe_row('*', 'txp_image', "name = '$name' limit 1");
}
elseif ($id)
{
$id = (int) $id;
$rs = safe_row('*', 'txp_image', "id = $id limit 1");
}
else
{
trigger_error(gTxt('unknown_image'));
return;
}
if ($rs)
{
extract($rs);
if ($thumbnail)
{
if ($escape == 'html')
{
$alt = escape_output($alt);
$caption = escape_output($caption);
}
$out = '<img src="'.hu.$img_dir.'/'.$id.'t'.$ext.'" alt="'.$alt.'"'.
($caption ? ' title="'.$caption.'"' : '').
( ($html_id and !$wraptag) ? ' id="'.$html_id.'"' : '' ).
( ($class and !$wraptag) ? ' class="'.$class.'"' : '' ).
($style ? ' style="'.$style.'"' : '').
($align ? ' align="'.$align.'"' : '').
' />';
if ($link || $poplink)
{
$out = '<a href="'.hu.$img_dir.'/'.$id.$ext.'">'.$out.'</a>';
}
return ($wraptag) ? doTag($out, $wraptag, $class, '', $html_id) : $out;
}
}
trigger_error(gTxt('unknown_image'));
}
// -------------------------------------------------------------
Offline
Offline
#6 2007-11-04 14:58:53
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Linking txp:thumbnail to full size img (w/o popup)
Offline
Offline