Skip to main content
FANCYBLOGGERTRICKS

follow us

How To Automatically Optimize Images For SEO


How To Automatically Optimize Images For SEO - Doing proper SEO is not only about doing keyword researchs and building strong back links, there are some little but vital SEO techniques to never forget, one is Image Optimization.

Why should I do Image Optimization?

Images have a great effect in a blogs seo and article ranking on search results. Google uses the keywords in your image alt text, alt title and src to display images each time a visitor searches a particular keyword. Image optimization also helps search engine bots to detect the meaning of your image from alt titles and texts.

How To Do Image Optimization For SEO.

Here is a previous post I made on how to improve SEO with image optimization. But optimizing each image can be very stressful which brings us to the main deal. Today I'll share how to automatically do Image optimization for SEO by just adding gas a javascript code in your blog template.

1. Login to blogger.com or draft.blogger.com
2. Navigate to Themes > Edit HTML.
3. Search for </body> or &lt;/body&gt , then copy and paste the below javascript code just above the body tag.

<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
$('img').each(function(){
var $img = $(this);
var filename = $img.attr('src')
$img.attr('alt', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));
});
});
//]]>
</script>
<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
$('img').each(function(){
var $img = $(this);
var filename = $img.attr('src')
$img.attr('title', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));
});
});
//]]>
</script>

4. Finally, Click on Save Template.

Important Notice. 

The above javascript code fetchs the image name and uses it as the alt text and alt title. So, always name your images with quality keywords.

That's all for today on How To Automatically Optimize Images For SEO. Save a friend by sharing this post on your social media networks. 

You Might Also Like:

Comment Policy: Please write your comments in accordance with the topic of this page post. Comments that contain links will not show up before they are approved
Open Comment