SEO Friendly Images - Version 2.2

Version Description

Download this release

Release Info

Developer freediver
Plugin Icon 128x128 SEO Friendly Images
Version 2.2
Comparing to
See all releases

Version 2.2

Files changed (9) hide show
  1. cafe.gif +0 -0
  2. help.png +0 -0
  3. home.png +0 -0
  4. idea.png +0 -0
  5. more.png +0 -0
  6. p1.png +0 -0
  7. readme.txt +66 -0
  8. seo-friendly-images.chk +2 -0
  9. seo-friendly-images.php +346 -0
cafe.gif ADDED
Binary file
help.png ADDED
Binary file
home.png ADDED
Binary file
idea.png ADDED
Binary file
more.png ADDED
Binary file
p1.png ADDED
Binary file
readme.txt ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === SEO Friendly Images ===
2
+ Contributors: freediver
3
+ Donate link: https://www.networkforgood.org/donation/MakeDonation.aspx?ORGID2=920155875
4
+ Tags: seo, images, Post, admin, google
5
+ Requires at least: 2.0
6
+ Tested up to: 2.5.1
7
+ Stable tag: 2.2
8
+
9
+ SEO Friendly Images automatically adds alt and title attributes to all your images. Improves traffic from search results and makes the tags w3c/xHTML valid as well.
10
+
11
+ == Description ==
12
+
13
+
14
+ SEO Friendly Images is a Wordpress optimization plugin which automatically updates all images with proper ALT and TITLE attributes. If your images do not have ALT and TITLE already set, SEO Friendly Images will add them according the options you set. Additionally this makes the post W3C/xHTML valid as well.
15
+
16
+ ALT attribute is important part of search engine optimization. It describes your image to search engine and when a user searches for a certain image this is a key determining factor for a match.
17
+
18
+ TITLE attribute play lesser role but is important for visitors as this text will automatically appear in the tooltip when mouse is over the image.
19
+
20
+ Changes
21
+ v2.2: Fixes an issue with poorly formatted img tag
22
+
23
+ v2.0: Fixed compability issue with WordPress 2.5.1 and included %category replacement string.
24
+
25
+ v1.1: Fixed quotes in title bug
26
+
27
+ == Installation ==
28
+
29
+ 1. Upload the whole plugin folder to your /wp-content/plugins/ folder.
30
+ 2. Go to the Plugins page and activate the plugin.
31
+ 3. Use the Options page to modify ALT and TITLE options.
32
+ 4. You are done, SEO Friendly Images does everything else
33
+
34
+ == License ==
35
+
36
+ This file is part of SEO Friendly Images.
37
+
38
+ SEO Friendly Images is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
39
+
40
+ SEO Friendly Images is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
41
+
42
+ You should have received a copy of the GNU General Public License along with SEO Friendly Images. If not, see <http://www.gnu.org/licenses/>.
43
+
44
+
45
+
46
+ == Frequently Asked Questions ==
47
+
48
+ = How do I correctly use this plugin? =
49
+
50
+ Just activating hte plugin will do the work. If you want to customize go to Settings, SEO Friendly Images and enter additional settings.
51
+
52
+ = How does SEO Friendly Images work? =
53
+
54
+ It replaces your image tags and ads ALT and TITLE tags which are essential for search engine optimization. This will result in more users to your site from the image search results.
55
+
56
+ = Is there anything else? =
57
+
58
+ Yes, oyu should create an account with Google Webmaster Central and enable enhnanced image indexing option for your website.
59
+
60
+ = Can I suggest an feature for the plugin? =
61
+
62
+ Of course, visit <a href="http://www.prelovac.com/vladimir/wordpress-plugins/seo-friendly-images#comments">SEO Friendly Images Home Page</a>
63
+
64
+ = I love your work, are you available for hire? =
65
+
66
+ Yes I am, visit my <a href="http://www.prelovac.com/vladimir/services">WordPress Services</a> page to find out more.
seo-friendly-images.chk ADDED
@@ -0,0 +1,2 @@
 
 
1
+ Version@2.0@
2
+ Message@<ul><li>2.5.1 compability and %category support.</li></ul>
seo-friendly-images.php ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ Plugin Name: SEO Friendly Images
5
+ Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/seo-friendly-images
6
+ Description: Automatically adds alt and title attributes to all your images. Improves traffic from search results and makes them W3C/xHTML valid as well.
7
+ Version: 2.2
8
+ Author: Vladimir Prelovac
9
+ Author URI: http://www.prelovac.com/vladimir
10
+
11
+ To-Do:
12
+ - localization
13
+
14
+
15
+ Copyright 2008 Vladimir Prelovac
16
+
17
+ */
18
+
19
+ $seo_friendly_images_localversion="2.2";
20
+
21
+ function seo_friendly_images_add_pages()
22
+ {
23
+ add_options_page('SEO Friendly Images options', 'SEO Friendly Images', 8, __FILE__, 'seo_friendly_images_options_page');
24
+ }
25
+
26
+
27
+
28
+ // Options Page
29
+ function seo_friendly_images_options_page()
30
+ {
31
+
32
+ global $seo_friendly_images_localversion;
33
+
34
+ $status=seo_friendly_images_getinfo();
35
+
36
+ $theVersion = $status[1];
37
+ $theMessage = $status[3];
38
+
39
+ if( (version_compare(strval($theVersion), strval($seo_friendly_images_localversion), '>') == 1) )
40
+ {
41
+ $msg = 'Latest version available '.' <strong>'.$theVersion.'</strong><br />'.$theMessage;
42
+ _e('<div id="message" class="updated fade"><p>' . $msg . '</p></div>');
43
+ }
44
+
45
+ // If form was submitted
46
+ if (isset($_POST['seo_friendly_images_update']))
47
+ {
48
+ $alt_text=(!isset($_POST['alttext'])? '': $_POST['alttext']);
49
+ $title_text=(!isset($_POST['titletext'])? '': $_POST['titletext']);
50
+ $override=(!isset($_POST['override'])? 'off': 'on');
51
+ update_option('seo_friendly_images_alt', $alt_text);
52
+ update_option('seo_friendly_images_title', $title_text );
53
+ update_option('seo_friendly_images_override', $override );
54
+
55
+ $msg_status = 'SEO Friendly Images options saved.';
56
+
57
+ // Show message
58
+ _e('<div id="message" class="updated fade"><p>' . $msg_status . '</p></div>');
59
+
60
+ }
61
+ else
62
+ {
63
+
64
+ // Fetch code from DB
65
+ $alt_text = get_option('seo_friendly_images_alt');
66
+ $title_text = get_option('seo_friendly_images_title');
67
+ $override = get_option('seo_friendly_images_override');
68
+
69
+ }
70
+ global $wp_version;
71
+ if(version_compare($wp_version,"2.5",">=")) {
72
+ _e('
73
+ <style type="text/css">
74
+ .wrap {
75
+ max-width:1000px !important;
76
+ }
77
+
78
+ div#moremeta {
79
+ float:right;
80
+ width:220px;
81
+ margin-left:10px;
82
+ }
83
+ div#advancedstuff {
84
+ width:770px;
85
+ }
86
+ div#poststuff {
87
+ margin-top:10px;
88
+ }
89
+ fieldset.dbx-box {
90
+ margin-bottom:5px;
91
+ }
92
+
93
+ </style>
94
+ <!--[if lt IE 7]>
95
+ <style type="text/css">
96
+ div#advancedstuff {
97
+ width:735px;
98
+ }
99
+ </style>
100
+ <![endif]-->
101
+
102
+ ');
103
+ }
104
+ // Configuration Page
105
+ _e('
106
+ <div class="wrap" id="options-div">
107
+ <form name="form_seo_friendly_images" method="post" action="' . $_SERVER['REQUEST_URI'] . '">
108
+ <h2>SEO Friendly Images '.$seo_friendly_images_localversion.'</h2>
109
+ <div id="poststuff">
110
+ <div id="moremeta">
111
+ <div id="sidebarBlocks" class="dbx-group">
112
+ <fieldset id="about" class="dbx-box">
113
+ <h3 class="dbx-handle">Information</h3>
114
+ <div id="dbx-content">
115
+ <img src="'. trailingslashit(get_option('siteurl')). 'wp-content/plugins/seo-image/home.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins/seo-image"> SEO Friendly Images Home</a><br /><br />
116
+ <img src="'. trailingslashit(get_option('siteurl')). 'wp-content/plugins/seo-image/idea.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins/seo-image#comments"> Suggest a Feature</a><br /><br />
117
+ <img src="'. trailingslashit(get_option('siteurl')). 'wp-content/plugins/seo-image/more.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins"> My WordPress Plugins</a><br /><br />
118
+ <br />
119
+
120
+ <p align="center">
121
+ <img src="'. trailingslashit(get_option('siteurl')). 'wp-content/plugins/seo-image/p1.png"></p>
122
+
123
+ <p> <img src="'. trailingslashit(get_option('siteurl')). 'wp-content/plugins/seo-image/help.png"><a href="http://www.prelovac.com/vladimir/services"> Need a WordPress Expert?</a></p>
124
+ </div>
125
+ </div>
126
+ </div>
127
+
128
+ <div id="advancedstuff">
129
+ <div id="mainBlocks" class="dbx-group" >
130
+ <div class="dbx-b-ox-wrapper">
131
+ <fieldset id="block-description" class="dbx-box">
132
+
133
+ <div class="dbx-h-andle-wrapper">
134
+ <h3 class="dbx-handle">Options</h3>
135
+ </div>
136
+
137
+ <div class="dbx-c-ontent-wrapper">
138
+ <div class="dbx-content">
139
+ <p>SEO Friendly Images automatically adds alt and title attributes to all your images in all your posts specified by parameters below.</p>
140
+ <p>You can enter any text in the field including two special tags:</p>
141
+ <ul>
142
+ <li>%title - replaces post title</li>
143
+ <li>%name - replaces image file name (without extension)</li>
144
+ <li>%category - replaces post category</li>
145
+ </ul>
146
+
147
+
148
+
149
+ <p><strong>SEO Friendly Images options</strong></p>
150
+
151
+
152
+ <div>
153
+ <label for="alt_text"><b>ALT</b> attribute (example: %name %title)</label><br>
154
+ <input style="border:1px solid #D1D1D1; width:165px;" id="alt_text" name="alttext" value="' .$alt_text.'"/>
155
+ </div><br>
156
+
157
+ <div>
158
+ <label for="title_text"><b>TITLE</b> attribute (example: %name photo)</label><br>
159
+ <input style="border:1px solid #D1D1D1; width:165px;" id="title_text" name="titletext" value="' .$title_text.'"/>
160
+ </div>
161
+
162
+ <br />
163
+ <div><input id="check1" type="checkbox" name="override"' .($override=="on"?'CHECKED':'').'/>
164
+ <label for="check1">Override default Wordpress alt (recommended)</label></div>
165
+
166
+
167
+
168
+
169
+ <br/><br /><p>Example:<br />
170
+ In a post titled Car Pictures there is a picture named Ferrari.jpg<br /><br />
171
+ Setting alt attribute to "%name %title" will produce alt="Ferrari Car Pictures"<br />
172
+ Setting title attribute to "%name photo" will produce title="Ferrari photo"</p>
173
+
174
+
175
+ <p class="submit">
176
+ <input type="submit" name="seo_friendly_images_update" value="Update Options &raquo;" />
177
+ </p>
178
+
179
+ </form>
180
+
181
+
182
+
183
+
184
+
185
+ </div>
186
+ </div>
187
+
188
+ </fieldset>
189
+
190
+ </div>
191
+ </div>
192
+ </div>
193
+ <h4>plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h4>
194
+ </div>
195
+
196
+ ');
197
+
198
+ }
199
+
200
+ // Add Options Page
201
+ add_action('admin_menu', 'seo_friendly_images_add_pages');
202
+
203
+
204
+ function remove_extension($name) {
205
+ return preg_replace('/(.+)\..*$/', '$1', $name);
206
+ }
207
+
208
+ function seo_friendly_images_process($matches) {
209
+
210
+ global $post;
211
+
212
+ $title = $post->post_title;
213
+
214
+ $alttext_rep = get_option('seo_friendly_images_alt');
215
+ $titletext_rep = get_option('seo_friendly_images_title');
216
+ $override= get_option('seo_friendly_images_override');
217
+
218
+ $matches=preg_replace('|"/$|', '" /', $matches);
219
+ ### Normalize spacing around attributes.
220
+ $matches[0] = preg_replace('/\s*=\s*/', '=', substr($matches[0],0,strlen($matches[0])-2));
221
+ ### Get source.
222
+ preg_match('/src\s*=\s*([\'"])?((?(1).+?|[^\s>]+))(?(1)\1)/', $matches[0], $source);
223
+ $saved=$source[2];
224
+
225
+ ### Swap with file's base name.
226
+ preg_match('%[^/]+(?=\.[a-z]{3}\z)%', $source[2], $source);
227
+ ### Separate URL by attributes.
228
+ $pieces = preg_split('/(\w+=)/', $matches[0], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
229
+ ### Add missing pieces.
230
+
231
+ $cats=get_the_category();
232
+ if (!in_array('title=', $pieces)) {
233
+ $titletext_rep=str_replace("%title", $post->post_title, $titletext_rep);
234
+ $titletext_rep=str_replace("%name", $source[0], $titletext_rep);
235
+ $titletext_rep=str_replace("%category", $cats[0]->slug, $titletext_rep);
236
+
237
+
238
+ $titletext_rep=str_replace('"', '', $titletext_rep);
239
+ $titletext_rep=str_replace("'", "", $titletext_rep);
240
+
241
+
242
+ array_push($pieces, ' title="' . $titletext_rep . '"');
243
+ }
244
+ if (!in_array('alt=', $pieces) ) {
245
+ $alttext_rep=str_replace("%title", $post->post_title, $alttext_rep);
246
+ $alttext_rep=str_replace("%name", $source[0], $alttext_rep);
247
+ $alttext_rep=str_replace("%category", $cats[0]->slug, $alttext_rep);
248
+
249
+ $alttext_rep=str_replace("\"", "", $alttext_rep);
250
+ $alttext_rep=str_replace("'", "", $alttext_rep);
251
+
252
+ array_push($pieces, ' alt="' . $alttext_rep . '"');
253
+ }
254
+ else
255
+ {
256
+
257
+ $key=array_search('alt=',$pieces);
258
+
259
+ if ((trim($pieces[$key+1])=='""') || (strpos($saved, str_replace('"','',trim($pieces[$key+1]))) && $override=="on"))
260
+ {
261
+
262
+ $alttext_rep=str_replace("%title", $post->post_title, $alttext_rep);
263
+ $alttext_rep=str_replace("%name", $source[0], $alttext_rep);
264
+ $alttext_rep=str_replace("%category", $cats[0]->slug, $alttext_rep);
265
+
266
+ $alttext_rep=str_replace("\"", "", $alttext_rep);
267
+ $alttext_rep=str_replace("'", "", $alttext_rep);
268
+
269
+ $pieces[$key+1]='"'.$alttext_rep.'" ';
270
+
271
+ }
272
+ }
273
+
274
+
275
+ return implode('', $pieces).' /';
276
+ }
277
+
278
+ function seo_friendly_images($content) {
279
+ return preg_replace_callback('/<img[^>]+/', 'seo_friendly_images_process', $content);
280
+ }
281
+
282
+
283
+ add_filter('the_content', 'seo_friendly_images', 50);
284
+
285
+ add_action( 'after_plugin_row', 'seo_friendly_images_check_plugin_version' );
286
+
287
+ function seo_friendly_images_getinfo()
288
+ {
289
+ $checkfile = "http://svn.wp-plugins.org/seo-image/trunk/seo-friendly-images.chk";
290
+
291
+ $status=array();
292
+ return $status;
293
+ $vcheck = wp_remote_fopen($checkfile);
294
+
295
+ if($vcheck)
296
+ {
297
+ $version = $seo_friendly_images_localversion;
298
+
299
+ $status = explode('@', $vcheck);
300
+ return $status;
301
+ }
302
+ }
303
+
304
+ function seo_friendly_images_check_plugin_version($plugin)
305
+ {
306
+ global $plugindir, $seo_friendly_images_localversion;
307
+
308
+ if( strpos($plugin,'seo-friendly-images.php')!==false )
309
+ {
310
+
311
+
312
+ $status=seo_friendly_images_getinfo();
313
+
314
+ $theVersion = $status[1];
315
+ $theMessage = $status[3];
316
+
317
+ if( (version_compare(strval($theVersion), strval($seo_friendly_images_localversion), '>') == 1) )
318
+ {
319
+ $msg = 'Latest version available '.' <strong>'.$theVersion.'</strong><br />'.$theMessage;
320
+ echo '<td colspan="5" class="plugin-update" style="line-height:1.2em;">'.$msg.'</td>';
321
+ } else {
322
+ return;
323
+ }
324
+
325
+ }
326
+ }
327
+
328
+
329
+
330
+ function seo_friendly_images_install(){
331
+ if(!get_option('seo_friendly_images_alt')){
332
+ add_option('seo_friendly_images_alt', '%name %title');
333
+ }
334
+ if(!get_option('seo_friendly_images_title')){
335
+ add_option('seo_friendly_images_title', '%title');
336
+ }
337
+ if(get_option('seo_friendly_images_override' == '') || !get_option('seo_friendly_images_override')){
338
+ add_option('seo_friendly_images_override', 'on');
339
+ }
340
+
341
+ }
342
+
343
+
344
+ add_action( 'plugins_loaded', 'seo_friendly_images_install' );
345
+
346
+ ?>