vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Changing Image Alt Text Using Replacement Variables (https://vborg.vbsupport.ru/showthread.php?t=294746)

dog-tag 02-04-2013 10:02 AM

Changing Image Alt Text Using Replacement Variables
 
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

kh99 02-04-2013 05:07 PM

Try:
Code:

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 -

Code:

alt="Click image for larger version. 

Name:        test 1.jpg 
Views:        0 
Size:        34.2 KB 
ID:        78672"/></a>
&nbsp;

Just tried -

Code:

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?

kh99 02-04-2013 08:47 PM

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}

kh99 02-05-2013 12:07 PM

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 :)

kh99 02-05-2013 02:33 PM

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.


All times are GMT. The time now is 06:09 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00974 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete