View Full Version : Changing Image Alt Text Using Replacement Variables
dog-tag
02-04-2013, 10:02 AM
Hey all :)
Just been trying to change my pesky image alt text using replacements variables.
My current alt text is -
alt="Click image for larger version.
(I think the lightbox feature creates this.)
Anyway I created a replacement variable like this -
REPLACE : alt="Click image for larger version
WITH : alt="$vboptions['bbtitle']
I also tried {options}, $vboptions['keywords'] and {title}
It will change the alt text but then the text is just {options} etc it won't pull the unique thread title or keywords into the alt text for me.
Can somebody tell me the correct code I need?
G
Try:
alt="{vb:raw vboptions.bbtitle}"
If your forum title has any special characters in it, you may need to do something a little different (It may be that " is the only character that would cause problems - I can't remember offhand).
dog-tag
02-04-2013, 06:22 PM
No that doesn't work either...
The whole source of the images are like this -
alt="Click image for larger version.
Name: test 1.jpg
Views: 0
Size: 34.2 KB
ID: 78672"/></a>
Just tried -
alt="click image for larger version.
replace with
alt="{vb:raw vboptions.bbtitle}
Tried with and without the " with your code, thanks for the reply Kevin!
Is there any where I can find that piece of code I need?
I probably should have asked, where are you doing this exactly? The curly brace replacements only work if you're putting that code in a template. Assuming you are and it didn't work, which template is it and what did you see?
dog-tag
02-05-2013, 05:46 AM
Hi Kevin,
I went into styles + termplates -> replacement variable manager -> add new replacement variable
I put the variable into my current custom theme (not the default vb one).
When I did the replace, I hovered the mouse over the image, alt text just reads {vb:raw vboptions.bbtitle}
When I view the source code in FF, it looks correct but the color of the text is now all red.
Before some of the text was blue, and this is what was the alt text I could read when hovering, but now the source code highlights it all as red.
So before I could read the lightbox alt text, filename, views and size
But now the alt (when hovering) just reads {vb:raw vboptions.bbtitle}
I'm sorry, I misunderstood what you were trying to do. The answer is that when you set up a replacement variable, you can't use a variable in the replacement text. (That just sounds wrong, I know, but it's true).
But you could just put your forum title in there, since I don't imagine it would change very often.
dog-tag
02-05-2013, 01:52 PM
haha OK
Can I insert thread keywords? thread title? thread description?
Anything at all related to the thread...
I tried the alt plugin by BOP5 but it wouldn't work. I also checked to see if VBSEO offered this but they don't (which I found very weird).
How do vBulletin users get loving from Google images? I'm finding it very hard and I have alot of images on my site... thanks for all the words of wisdom Kevin :)
I guess the way to do it is to have a plugin put together a string from whatever values you want, then register that to the template and use a curly brace thing in the template. But I know not everyone is in to that kind of programming, and I don't know if any mods exist already. Hopefully someone else will.
dog-tag
02-06-2013, 07:48 AM
Damn it to hell, hmmm think I'll have to make a paid request and see what happens.
Thanks alot for the input, hopefully I can make something work and share it here on the forum.
Digital Jedi
02-06-2013, 01:34 PM
One of the articles in the Articles Forum is a tutorial on how to do a simple string replace using plugins. It might need some tweaking for vB4, but it might be just what you needed.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.