Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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/

share|improve this question
    
Tried looking at the .js file here: mbigelowphotographer.com/wp/wp-content/plugins/nextgen-gallery/… which seems to be generating the navigation buttons and whatnot, but not seeing how it is pulling the title tags from the links. Good luck. –  GhostToast Dec 28 '12 at 15:50
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
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. –  AndrewChambers Dec 28 '12 at 19:26
    
No problem, glad it worked. Feel free to upvote and/or accept the answer if it was helpful. –  Jared Cobb Dec 28 '12 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. –  AndrewChambers Dec 28 '12 at 21:25
add comment

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 : '';
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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