Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-10-29 23:51:38

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

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

#2 2007-11-03 04:15:38

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

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

#4 2007-11-03 20:18:52

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

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

#5 2007-11-03 20:59:20

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Linking txp:thumbnail to full size img (w/o popup)

A little one-line fix, but great advantage :-) Sounds great if it will become part of the core.

Cheers!

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

#7 2007-11-10 03:30:14

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Linking txp:thumbnail to full size img (w/o popup)

Thanks Mary!

Offline

Board footer

Powered by FluxBB