00657: Add "title" attribute to external links.

Summary: Add "title" attribute to external links.
Created: 2006-02-01 15:23
Status: Closed - added for 2.2.14
Category: Feature
From: Pm
Assigned:
Priority: 55555 55555 44442 2
Version: 2.1.beta21
OS:

Description: Add "title" capability to external links.


See also PITS.01172 Add "title" attribute to internal links..


Note that you can already have link titles for external links

[[http://www.wikipedia.org/"The free encyclopedia"|Wikipedia]] will print Wikipedia and a tooltip "The free encyclopedia".

To enable this, you may need to set in your config.php this line:

 $UrlLinkFmt = "<a class='urllink' href='\$LinkUrl' rel='nofollow' title='\$LinkAlt'>\$LinkText</a>";

I'm not sure why this is for external links and not just links.

I think it should be for:

  • internal/external Links
  • Images (where alt/title/tool tip already exist)
  • Intermap Links

For internal links it would be nice to be able to have, as a disabled-by-default option of course, the title attribute automatically be the $Title(spaced) of the target page for an internal link.

Here's the current proposed syntax:

 [[ http://example.com | Link text ]]
 [[ http://example.com | | Title text ]]
 [[ http://example.com | Link Text | Title text ]]
 [[ Link Text -> http://example.com ]]
 [[ Link Text -> http://example.com | Title text ]]

For images,

 Attach:image.jpg"Alt text"
 Attach:image.jpg"Alt text" | Caption text
 Attach:image.jpg"Alt text" | | Title text
 Attach:image.jpg"Alt text" | Caption text | Title text
 Attach:image.jpg | Caption text
 Attach:image.jpg | | Title text
 Attach:image.jpg | Caption text | Title text

Hagan - 2006-04-02

I very strongly support the addition of a title attribute. About the "default title" (when there is none defined) I think in Mediawiki they did it quite simple and effective - if it is an external link, the title is the URL, if it is a wiki page, the title is the page name (and not the page title as opening all linked pages will slow things very much). Same for the image and attachment titles -- at least have an alt and title attribute showing the file name. --Petko

cg - 2006-08-27

There is a title attribute (title=...) for images, s. Version 2.0.beta52 (29-Jul-2005), ChangeLog. I think there should be _no_ default title for links! Btw be careful and do not mistake the behaviour of alt- and title-tag in IE and Mozilla. Unfortunately the alt tag is implemented wrong in IE. It is displayed even when an image exists.

Scott Connard - 2006-08-27

This would be a good feature to add, but there should certainly be a way to have no default titles. This could be an option which could be invoked by group/site, etc with local configurations.

Pico - 2007-06-02

If we are taking a look at title support and markup more generally, we should consider whether we want to support acronyms, as in:

<acronym title="cascading style sheets">CSS</acronym>

To keep it intuitive, perhaps we could piece together markup using quotations and a pipe, like this:

CSS|"cascading style sheet" or
CSS|'cascading style sheet'

If we want to require that text after the first pipe appears on the page, and text after the second pipe is treated as the title, then we could try something like:

|CSS|"cascading style sheet" or
|CSS|'cascading style sheet'

Or, if that creates conflicts with other markup, perhaps we could require quotes on each portion, like:

|"CSS"|"cascading style sheet" or
|'CSS'|'cascading style sheet'

One more idea, only this time adding a parens to signify that text should be hidden from the displayed text:

CSS|("cascading style sheet")

Still not done, another idea, using a second parens to cause text to be hidden and used as title::

CSS(("cascading style sheet"))

I fully support alt and title attributes in links and images (internal and external). However, I also feel that there should be a new entry in config.php that allows the user to disable either title, or alt, or both - maybe disabled by default and the user can enable to suit them. There may be people who just want a title, and some who just want alt, and still some who want none or both.

Ian MacGregor - 2007-06-11

I agree with Hagan that this should be implemented for internal links as well. Thanks, BTW, to whoever put the note at the top on how to enable it for external links.

Andy Standfield -2008-03-13


Implemented syntax

From version 2.2.14 PmWiki can show tooltip titles with the following format:

* External link: [[http://pmwiki.org"PmWiki home" | external link ]], the title is "PmWiki home"
* [[PmWiki/InterMap]] link: [[Wikipedia:Wiki"Article on Wikipedia"| InterMap link ]], the title is "Article on Wikipedia"
* Linked image: [[Attach:000962.png"Uploaded file" | Attach: link]], the title is "Uploaded file".
* Inline image: Attach:000962.png"Logo", the alt/title is "Logo".