Advertisement:

Author Topic: Your Image alt and title tag  (Read 3164 times)

tonysar

  • Jr. Member
  • **
  • Posts: 62
Your Image alt and title tag
« on: December 30, 2011, 06:44:31 pm »
Hello.
as we all know , search engines  index many part of your site . images are also included . as such , images contain both alt and title . having some information for your image , not only will help visually impaired users , but also help your site to rank much better on the net.

currently osclass image ALT and Title is not pulling anything . but you can fix that easy. you need to alter 3 files from your theme file section .
main.php
item.php  ( for item.php i suggest only alt tag for large image )
search_list.php

i used the following code for ALT tag

alt =  "<?php echo osc_item_title() ; ?>"

and for TITLE tag

title =" <?php echo osc_highlight( strip_tags( osc_item_description() ), 25 ) ; ?> "

osc_item_description will pull listing description , but i did limit the description in this case to 25 characters .you can increase  or decrease the number . or you can apply only php code with in alt tag to both alt and title tag.

hope this helps out .


_CONEJO

  • Administrator
  • Hero Member
  • *****
  • Posts: 4689
Re: Your Image alt and title tag
« Reply #1 on: January 02, 2012, 11:29:42 am »
Hi tonysar,

Thanks for the suggestion. I've just created an issue so you could follow the development here : https://github.com/osclass/OSClass/issues/101


Thanks a lot!!

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: Your Image alt and title tag
« Reply #2 on: January 02, 2012, 12:37:30 pm »
tonysar,

Very nice! Simple and effective. That should be a simple fix/addition for the team. I'll make that change for myself as well.  :D



EDIT:  I'll probably just set both the alt and title to osc_item_title(). Why? Because there is no telling if the first 25 characters (or whatever it's set to) will give any kind of accurate description, whereas the item_title definitely will.  ;D
« Last Edit: January 02, 2012, 04:48:15 pm by Jesse »

maia_x

  • Newbie
  • *
  • Posts: 38
Re: Your Image alt and title tag
« Reply #3 on: February 01, 2012, 03:23:25 pm »
Hello everyone,
I leave a little note if you want the same title also appears in fancybox instead of "Image 1 of 1".

Since some titles have special characters, the function <?php echo osc_item_title(); ?> may not work properly.

On theme's page item.php replace:
Code: [Select]
return '<span id="fancybox-title-over"> <? php _e (' Image ',' modern ');?>' + (currentIndex + 1) + '/' + currentArray.length + '' + title + '</ span>';
with this:

 
Code: [Select]
return '<span id="fancybox-title-over"> <? php echo htmlentities (osc_item_title (), ENT_QUOTES | ENT_IGNORE, "UTF-8");?>;' + (currentIndex + 1) + '/' + currentArray.length + '' + title + '</ span>';

I hope it can be useful

cosmicx

  • Jr. Member
  • **
  • Posts: 73
Re: Your Image alt and title tag
« Reply #4 on: February 08, 2012, 06:19:23 pm »
@tonysar

wow! great share... what if i wanted to create a backend settings for this? how do i accomplish that?

the backend end settings is for the title tag, to set the limit of the numbers of characters allowed to pull from the listing description. and also a settings so as the admin may include a additional text or word or phrase in the title attribute or alt attribute.

it's like this:

alt =  "<?php echo osc_item_title() ; - my additional text?>"  = so that it will be rendered as, Item Title - My Text


title =" <?php echo osc_highlight( strip_tags( osc_item_description() ), 25 ) ; - my additional text ?> " = so that it will be rendered as, Item Description - My Text

plus, the settings will let you choose if the additional text you want to add is to prefix or to suffix the alt or title.