4

Okay,here's my challenge. My client doesn't like how when you roll over an image in the gallery a tooltip shows up with the image's descritpion, which is taken from it's title tag. But he still wants the image description to show up as the caption when you click on the image and enlarge it.

Here is a link to a page in the site, if you roll over the first image in the gallery, you'll see what I'm talking about and hopefully it'll make sense. http://mbigelowphotographer.com/wp/engagements

I've tried to find ways on hiding browser default tooltips but I've had no luck. So I thought of placing the image's description in the images alt tag instead of the title tag. Which is fine, I took care of that in the gallery.php file.

But now I can't figure out where in the shutter-reloaded.js, for the image caption to pull the alt tag instead of the title tag. I'm hoping its a simple solution that I'm just overlooking since I am only vaguely familiar with javascript.

Or maybe I'm way off and it's not in that js file. Any help would be appreciated. Thanks in advance.

I am sure I'm being vague in my description here, don't hesitate to ask for more details.

http://wordpress.org/extend/plugins/nextgen-gallery/

1

2 Answers 2

2

You're in the right file, shutter-reloaded is where you'll want to make the change.

It looks like the gallery plugin is parsing the entire document for its links to start. That function is called init on line 34. Inside that function, the plugin is going to loop through all the links on the page and determine if it's a valid gallery thumbnail.

The line you're interested in is going to be line 61. The plugin is inspecting the title attribute of the link to determine if it should use it, and then it'll assign it to the variable T.

If you replace line 61 with the following 2 lines of code, it should work.

var linkAlt = jQuery(L).attr('alt');
T = ( linkAlt && linkAlt != shfile ) ? linkAlt : '';

Those lines will get the alt text content, assign it to a variable named linkAlt, and then continue with the plugin's original logic of making sure it's not the same as the filename (for some reason).

[edit]

Also, just keep in mind that if you change the source code of a plugin you'll lose those changes if you update it.

3
  • Awesome! It worked. Thanks for your help Jared. I appreciate you taking the time to look into it. I messed around on this problem for like 3 days trying to get it figured out. Happy New Year to you. Take care. Commented Dec 28, 2012 at 19:26
  • No problem, glad it worked. Feel free to upvote and/or accept the answer if it was helpful.
    – Jared Cobb
    Commented Dec 28, 2012 at 20:31
  • Ah, sorry, I'm new to this. Didn't know about that. Just had a buddy chastise me for not doing that. ;) Thanks again. Commented Dec 28, 2012 at 21:25
1

Jared Cobb's solution relies on jquery. You can do without by instead using

var linkAlt = L.getElementsByTagName("img")[0]['alt']
T = ( linkAlt && linkAlt != shfile ) ? linkAlt : '';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.