IT Blog

  • Blog
  • Technology
    • Technology
    • Architecture
    • CMS
    • CRM
    • Web
    • DotNET
    • Python
    • Database
    • BI
    • Program Language
  • Users
    • Login
    • Register
    • Forgot Password?
  • ENEN
    • 中文中文
    • ENEN
Experience IT
In a World of Technology, People Make the Difference.
  1. Home
  2. Technology
  3. CMS
  4. Wordpress
  5. Plugin
  6. Add ALT attribute to Social Media Icon

Add ALT attribute to Social Media Icon

2021-12-03 338 Views 5 Like 0 Comments

AlT attribute for an image is helpful factor for SEO. But the plugin "Social Media Share Buttons" by Sygnoos is not adding alt attribute for all social images. The following is my approach to add alt attribute to the social images. For this reason, Bing search console is always give a warning message and refuse to index the site.

1. Find possible keyword using browser tool.

find-keyword-in-browser

2. locate keyword using Visual Studio find feature. Location: /wp-content/plugins/social-media-builder/js/addNewSection/SGMBWidget.js

locate-keyword

3. add alt attribute to the images with jQuery.

add-alt

4. result:

alt-added

Additionary, to set all images ALT value where alt is missing, using this script:

Set alt value to image file name where alt is missing
$('img').each(function(i,e){
if($(e).attr('alt')=='')
$(e).attr('alt', $(e).attr('src').replace(/^.*(\\|\/|\:)/, '').replace(/\.[^/.]+$/,''));
});

How to get this script? Explained below.

//show all img src
$('img').each(function(i,e){console.log($(e).attr('src'));});
//show all img alt
$('img').each(function(i,e){console.log($(e).attr('alt'));});

//get file name from path
filepath.replace(/^.*(\\|\/|\:)/, '');
//get file name without extension from file name
filename.replace(/\.[^/.]+$/,'');

//show all img file name without extension
$('img').each(function(i,e){console.log($(e).attr('src').replace(/^.*(\\|\/|\:)/, '').replace(/\.[^/.]+$/,''));});
//set alt value to image file name where alt is missing
$('img').each(function(i,e){if($(e).attr('alt')=='') $(e).attr('alt', $(e).attr('src').replace(/^.*(\\|\/|\:)/, '').replace(/\.[^/.]+$/,''));});

 

 1,001 total views,  2 views today

error
fb-share-icon
Tweet
fb-share-icon
IT Team
Author: IT Team

Tags: Blog
Last updated:2021-12-03

IT Team

This person is lazy and left nothing

Like
< Previous

Comments

Cancel reply
Chinese (Simplified) Chinese (Simplified) Chinese (Traditional) Chinese (Traditional) English English French French German German Japanese Japanese Korean Korean Russian Russian
Newest Hotspots Random
Newest Hotspots Random
Rich editor not working Making web page scroll down automatically Getting data from Dapper result All Unicode Chars How to keep and display contact form 7 data Common Regular Expressions
Change Event Calendar Title JQuery get checkbox value Hide empty custom fields in Ultimate product catelog plugin How to block bad bots in Appache server WordPress EventCalendar visibility Apostrophe menu font too big
Categories
  • Architecture
  • BI
  • C#
  • CSS
  • Database
  • DotNET
  • Hosting
  • HTML
  • JavaScript
  • PHP
  • Program Language
  • Python
  • Security
  • SEO
  • Technology
  • Web
  • Wordpress

COPYRIGHT © 2021 Hostlike IT Blog. All rights reserved.

This site is supported by Hostlike.com