[SEO] Better Alt Description For Images In PHPBB3

Status
Not open for further replies.

pi0tr3k

Active Member
3,055
2009
768
10
As everyone knows, standard phpbb3 doesn't have proper ALT & TITLE attributes for images in viewtopic body...

Here is a little tutorial on how to provide better ALT attributes for images in phpbb3 :)

Why should you change your ALT= attribute on your phpbb3 board?
Optimizing images is becoming more and more important in SEO (Search Engine Optimization) for websites. The ALT attribute is a critical step that is often overlooked. This can be a lost opportunity for better rankings.

In Google’s webmaster guidelines, they advise the use of alternative text for the images on your web site:

Images:. Use the alt attribute to provide descriptive text. In addition, we recommend using a human-readable caption and descriptive text around the image.

Original source: Alt Attribute & Image Search Engine Optimization - SEO Workers
http://www.seoworkers.com/seo-articles-tutorials/alt-attribute.html#ixzz1fsjo012W
Under Creative Commons License: Attribution No Derivatives

There is a simple fix, one file edit actually, to make it work to your needs. As everyone knows, in standard phpBB3 version, the alt= attribute looks like: alt="Image", and this is not so good for SEO ( Search Engine Optimization ).

After reading this tutorial, your alt= attribute on every image posted in a topic will have the following format:
alt="topic title comes here" title="topic title comes here"


Let's start.

1) Backup the file bbcode.php from /includes/ (downloading to your desktop is the best option)

2) Open /includes/bbcode.php

3) Near the lines 420-430, look for the following code:
Code:
'img'      => '<img src="$1" alt="' . $user->lang['IMAGE'] . '" />',

4) Replace the whole line by the following code:
Code:
'img'      => '<img src="$1" ' . ((isset($topic_data)) ? 'title="' . $topic_data['topic_title'] . '"' : "") . 'alt="' . (isset($topic_data) ? $topic_data['topic_title'] : $user->lang['IMAGE']) . '" />',

5) Find global $user; and change it to global $user, $topic_data; (This line is located around line 421, before $bbcode_hardtpl = array( , same file)

6) Save & upload your file.

7) Done.



Result:
Right click on my signature and choose "View Image Info":
tmpa200.png


Note: this will not override an already existing alt= attribute.


I hope this will help you all, good luck on getting more images indexed!

More Support,click here.



Cheers!
 
Status
Not open for further replies.
Back
Top