News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Replace image alt with page_title_html_safe only in threads

Started by Nirose, January 31, 2017, 12:56:30 AM

Previous topic - Next topic

Nirose

I added a code inside Subs.php to make img alt attribute contain the title of the thread. But it logs an error on other pages where it cannot be found as in profile and xml feed. I just want to make it load inside of threads.

I tried isset($context['page_title_html_safe']) and !empty($context['page_title_html_safe']) to only load when the index is available but that makes the forum stop working.

'content' => '<img src="$1" alt="' . $context['page_title_html_safe'] . '" class="bbc_img" />',

Just want to error proof it.

Thanks in advance

Kindred

you want to make every BBC image have the path title as the alt text?   Why would you ever do that?

That defeats the basic intention of the alt text
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Nirose

Quote from: Kindred on January 31, 2017, 08:33:03 AM
you want to make every BBC image have the path title as the alt text?   Why would you ever do that?

That defeats the basic intention of the alt text

Thanks for the reply but NO!! i want the image that are untagged with an alt attribute to use the titles. I don't see how it defeats the basic intention of alt text.

I can add BBC image alt tags for my own posts but i can't expect everyone to do that.

The option is going without an alt tag or having a title as one.  I am experimenting if having it does anything good. May be just on the first post, but i still want to try it.

Thanks again

Kindred

the point of the point of the alt tag is three fold - all three of which are "violated" by your intended update

1- to display a description of the image for non-visual viewers (e.g. blind readers - the blind reader browser displays the alt tag in braille)
2- to give spiders something to tag when they browse the page (they can't see the image, but they read the filename and alt tag)
3- to display some text in place of the image when the image is broken.


Putting in the page title for any image without an alt tag violates the precept of what an alt tag is (and may actually affect your SEO, poorly)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Nirose

I understand that completely. i actually have read the usage and best practices before i posted. and it was a test on my end, and i tweaked it a fair bit. it helped a little bit but not much.

Thanks for your input. :)

Advertisement: