Add title attribute to all links

nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2005-05-07 19:41

What file do I edit to add the title attribute to image links. The alt attribute is already there. I tried searching through the core module for this information, but can't find it and really have no clue as to where to start except at gallery2/.....

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2005-05-07 20:16

if you want to add it in a particular place you can pass title= in the g->image.
if you want to modify all of them, edit modules/core/classes/GalleryPhotoItem.class and GalleryDerivativeImage.class, function render().

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2005-05-07 20:18
mindless wrote:
f you want to modify all of them, edit modules/core/classes/GalleryPhotoItem.class and GalleryDerivativeImage.class, function render().

Are classes similar to templates where I should make a local directory so I don't have to worry about them getting written over?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2005-05-07 20:35

nope, sorry.. you'll have to manage changes you make to classes..

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2005-05-07 20:45

No problem. Thanks for the info. It worked perfectly!

 
astus

Joined: 2005-04-24
Posts: 8
Posted: Sat, 2005-05-07 21:56
nivekiam wrote:
No problem. Thanks for the info. It worked perfectly!

sorry, i think i didnt understood. how to make the names of images in alt attributes, so I see the name on mouseover?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2005-05-07 22:45

edit: I've added a feature request for this that can be found here, https://sourceforge.net/tracker/index.php?func=detail&aid=1198718&group_id=7130&atid=357130. There's an attached file with all the modifications needed to 29 files to make these changes.

Edit the two files mindless mentions above. Towards the bottom of each file there is a function defined named render It starts with this:

    /**
     * @see GalleryDerivative::render()
     */
    function render($format, $item, $params) {

Find these lines towards the lower portion of that function:

            if (!isset($params['alt'])) {
                $params['alt'] = $item->getTitle() ? $item->getTitle() : $item->getPathComponent();
            }
            if (!isset($params['longdesc'])) {
                $params['longdesc'] = preg_replace('/[\r\n]+/', ' ', $item->getDescription());
            }

and add these lines of code

            if (!isset($params['title'])) {
                $params['title'] = $item->getTitle() ? $item->getTitle() : $item->getPathComponent();
            }

The result should look something like this

            if (!isset($params['alt'])) {
                $params['alt'] = $item->getTitle() ? $item->getTitle() : $item->getPathComponent();
            }
            if (!isset($params['title'])) {
                $params['title'] = $item->getTitle() ? $item->getTitle() : $item->getPathComponent();
            }
            if (!isset($params['longdesc'])) {
                $params['longdesc'] = preg_replace('/[\r\n]+/', ' ', $item->getDescription());
            }