Forums › Forums › Slimbox2 plugin › Use title tag of img as caption if title of a href is not available?
- This topic has 9 replies, 3 voices, and was last updated 15 years, 1 month ago by Anonymous.
-
AuthorPosts
-
February 15, 2009 at 2:51 pm #639lemonteaMember
The current one takes the title tag inside the ahref as captions. I was wondering if it’s possible to take the title tag of the img tag if there’s no title tag in the ahref? Because using the WP default upload function, the title tag doesn’t appear in the ahref but the img instead.
Is that possible? ” title=”Smiley” />
February 15, 2009 at 11:03 pm #5352malcalevakModeratorYes, I believe it is possible, but I’d need to look up the code to modify it to accommodate for this.
February 16, 2009 at 1:07 am #5353lemonteaMemberRight, hopefully this feature will be implemented in the future. Thank you so much, this plugin is great! ” title=”Smiley” />
August 23, 2009 at 3:28 pm #5354AnonymousMemberAny progress on this? I constantly run into this issue because I like to spread out the pictures in my posts rather than group them together in a gallery so I have to go in and manually add title="whatever" to all my <a> image links. I was going to dive into the code and try to figure that out, but just wondering if someone has already done it so I do not have to reinvent the wheel ” title=”Smiley” />
August 24, 2009 at 3:55 am #5355malcalevakModeratorI unfortunately haven’t had much time to do any work on the plugin, though I want to say that I believe the javascript’s API does support this. You can check on the developers site if you like.
In the meantime, I’ve really been hoping to find the time to work on the plugin.
August 26, 2009 at 2:03 am #5356AnonymousMemberOk, I found this:
http://groups.google.com/group/slimbox- … 9d7b06b87#So, looks like it is possible to use the alt (or possible even title) tag of the image instead of the title tag of <a>.
However, I cannot find the snippet of code mentioned in that post anywhere in wp-slimbox2 directory. What am I missing?October 6, 2009 at 10:16 am #5357AnonymousMemberUsing that code you linked to from the Google group, I think I have this working. Not tested properly though, so all feedback appreciated!
You need to edit the slimbox2_autoload.js.php file in the javascript folder. Around line 16 you will see an if and else where $autoLoad is set. In both branches, change the parameters for the call to slimbox as follows:
change the bit .slimbox(options, null, function(el)
to .slimbox(options, linkmapper, function(el)Then you need to add a simple linkmapper function to the file to get things working. I added in the following lines just under the if else branch, above the echo where the main jQuery(function($){ is output:
//#function to use titles from images as slimbox captions
echo ‘
function linkmapper(el) {
return [el.href, el.title || el.firstChild.alt];
}
‘;Hope this works for others and helps you out ” title=”Smiley” />
October 6, 2009 at 10:36 am #5358AnonymousMemberSmall typo in my last post. I’d copied the function direct from the Google thread where the alt attribute was wanted as the caption. Here we’d like the image title attribute instead so the function should be:
return [el.href, el.title || el.firstChild.title];
October 6, 2009 at 12:43 pm #5359malcalevakModeratorThanks for figure that out, Janine. Looking it over, it appears sound, though I haven’t tested it myself.
I’ve been so ridiculously busy with my real job that I just haven’t had time to work on WP-Slimbox2.
I’m hoping to get some time to work on the successor to the plugin, and also a maintenance release incorporating your suggestion as well as a few others.
Thanks again for figuring this out.
October 7, 2009 at 1:16 pm #5360AnonymousMemberJanine,
I made the changes last night and got it to work for me as well. Thanks a lot!
Dima
-
AuthorPosts
- You must be logged in to reply to this topic.