Auto Image Attributes From Filename With Bulk Updater (Add Alt Text, Image Title For Image SEO) - Version 1.2

Version Description

  • Added: Character filter options. Plugin now removes hyphens and underscores.
  • Bug Fix: Minor bug fix.
Download this release

Release Info

Developer arunbasillal
Plugin Icon 128x128 Auto Image Attributes From Filename With Bulk Updater (Add Alt Text, Image Title For Image SEO)
Version 1.2
Comparing to
See all releases

Code changes from version 1.1 to 1.2

iaff_image-attributes-from-filename.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://millionclues.com/portfolio/
5
  Description: Automatically Add Image Title, Image Caption, Description And Alt Text From Image Filename. Since this plugin includes a bulk updater this can update both existing images in the Media Library and new images.
6
  Author: Arun Basil Lal
7
  Author URI: http://millionclues.com
8
- Version: 1.1
9
  Text Domain: abl_iaff_td
10
  Domain Path: /languages
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@@ -85,7 +85,7 @@ function iaff_register_settings() {
85
  'image-attributes-from-filename' // Page slug
86
  );
87
 
88
- // Setting: Enable Auto Image Attributes
89
  add_settings_field(
90
  'iaff_general_settings', // ID
91
  __('General Settings', 'abl_iaff_td'), // Title
@@ -94,6 +94,15 @@ function iaff_register_settings() {
94
  'iaff_auto_image_attributes_settings' // Settings Section ID
95
  );
96
 
 
 
 
 
 
 
 
 
 
97
  }
98
  add_action( 'admin_init', 'iaff_register_settings' );
99
 
@@ -116,7 +125,7 @@ function iaff_auto_image_attributes_callback() {
116
  echo '<p>' . __('Automatically add Image attributes such as Image Title, Image Caption, Description And Alt Text from Image Filename for new uploads.', 'abl_iaff_td') . '</p>';
117
  }
118
 
119
- // Settings Field Callback
120
  function iaff_auto_image_attributes_settings_field_callback() {
121
 
122
  // Default Values For Settings
@@ -159,6 +168,33 @@ function iaff_auto_image_attributes_settings_field_callback() {
159
  <?php
160
  }
161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  // Admin Interface Renderer
163
  function iaff_admin_interface_render () {
164
 
@@ -230,29 +266,38 @@ function iaff_auto_image_attributes( $post_ID ) {
230
  'image_title' => '1',
231
  'image_caption' => '1',
232
  'image_description' => '1',
233
- 'image_alttext' => '1'
 
 
234
  );
235
  // Get Settings
236
  $settings = get_option('iaff_settings', $defaults);
237
 
238
  $attachment = get_post( $post_ID );
239
  $attachment_title = $attachment->post_title;
240
- $attachment_title = str_replace( '-', ' ', $attachment_title ); // Hyphen Removal
 
 
 
 
 
 
 
241
  $attachment_title = ucwords( $attachment_title ); // Capitalize First Word
242
 
243
  $uploaded_image = array();
244
  $uploaded_image['ID'] = $post_ID;
245
 
246
- if ( boolval($settings['image_title']) ) {
247
  $uploaded_image['post_title'] = $attachment_title; // Image Title
248
  }
249
- if ( boolval($settings['image_caption']) ) {
250
  $uploaded_image['post_excerpt'] = $attachment_title; // Image Caption
251
  }
252
- if ( boolval($settings['image_description']) ) {
253
  $uploaded_image['post_content'] = $attachment_title; // Image Description
254
  }
255
- if ( boolval($settings['image_alttext']) ) {
256
  update_post_meta( $post_ID, '_wp_attachment_image_alt', $attachment_title ); // Image Alt Text
257
  }
258
 
@@ -286,6 +331,7 @@ function iaff_rename_old_image() {
286
 
287
  // Process the image name and neatify it
288
  $image_name = str_replace( '-', ' ', $image_name ); // replace hyphens with spaces
 
289
  $image_name = ucwords( $image_name ); // Capitalize each word
290
 
291
  // Update the image Title, Caption and Description with the image name
5
  Description: Automatically Add Image Title, Image Caption, Description And Alt Text From Image Filename. Since this plugin includes a bulk updater this can update both existing images in the Media Library and new images.
6
  Author: Arun Basil Lal
7
  Author URI: http://millionclues.com
8
+ Version: 1.2
9
  Text Domain: abl_iaff_td
10
  Domain Path: /languages
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
85
  'image-attributes-from-filename' // Page slug
86
  );
87
 
88
+ // General Settings
89
  add_settings_field(
90
  'iaff_general_settings', // ID
91
  __('General Settings', 'abl_iaff_td'), // Title
94
  'iaff_auto_image_attributes_settings' // Settings Section ID
95
  );
96
 
97
+ // Filter Settings
98
+ add_settings_field(
99
+ 'iaff_filter_settings', // ID
100
+ __('Filter Settings', 'abl_iaff_td'), // Title
101
+ 'iaff_auto_image_attributes_filter_settings_callback', // Callback function
102
+ 'image-attributes-from-filename', // Page slug
103
+ 'iaff_auto_image_attributes_settings' // Settings Section ID
104
+ );
105
+
106
  }
107
  add_action( 'admin_init', 'iaff_register_settings' );
108
 
125
  echo '<p>' . __('Automatically add Image attributes such as Image Title, Image Caption, Description And Alt Text from Image Filename for new uploads.', 'abl_iaff_td') . '</p>';
126
  }
127
 
128
+ // General Settings Field Callback
129
  function iaff_auto_image_attributes_settings_field_callback() {
130
 
131
  // Default Values For Settings
168
  <?php
169
  }
170
 
171
+ // Filter Settings Field Callback
172
+ function iaff_auto_image_attributes_filter_settings_callback() {
173
+
174
+ // Default Values For Settings
175
+ $defaults = array(
176
+ 'hyphens' => '1',
177
+ 'under_score' => '1',
178
+ );
179
+
180
+ // Get Settings
181
+ $settings = get_option('iaff_settings', $defaults); ?>
182
+
183
+ <!-- Filter Hyphens -->
184
+ <input type="checkbox" name="iaff_settings[hyphens]" id="iaff_settings[hyphens]" value="1"
185
+ <?php if ( isset( $settings['hyphens'] ) ) { checked( '1', $settings['hyphens'] ); } ?>>
186
+ <label for="iaff_settings[hyphens]"><?php _e('Remove hyphens ( - ) from filename', 'abl_iaff_td') ?></label>
187
+ <br>
188
+
189
+ <!-- Filter Underscore -->
190
+ <input type="checkbox" name="iaff_settings[under_score]" id="iaff_settings[under_score]" value="1"
191
+ <?php if ( isset( $settings['under_score'] ) ) { checked( '1', $settings['under_score'] ); } ?>>
192
+ <label for="iaff_settings[under_score]"><?php _e('Remove underscores ( _ ) from filename', 'abl_iaff_td') ?></label>
193
+ <br>
194
+
195
+ <?php
196
+ }
197
+
198
  // Admin Interface Renderer
199
  function iaff_admin_interface_render () {
200
 
266
  'image_title' => '1',
267
  'image_caption' => '1',
268
  'image_description' => '1',
269
+ 'image_alttext' => '1',
270
+ 'hyphens' => '1',
271
+ 'under_score' => '1',
272
  );
273
  // Get Settings
274
  $settings = get_option('iaff_settings', $defaults);
275
 
276
  $attachment = get_post( $post_ID );
277
  $attachment_title = $attachment->post_title;
278
+
279
+ if ( isset( $settings['hyphens'] ) && boolval($settings['hyphens']) ) {
280
+ $attachment_title = str_replace( '-', ' ', $attachment_title ); // Hyphen Removal
281
+ }
282
+ if ( isset( $settings['under_score'] ) && boolval($settings['under_score']) ) {
283
+ $attachment_title = str_replace( '_', ' ', $attachment_title ); // Underscore Removal
284
+ }
285
+
286
  $attachment_title = ucwords( $attachment_title ); // Capitalize First Word
287
 
288
  $uploaded_image = array();
289
  $uploaded_image['ID'] = $post_ID;
290
 
291
+ if ( isset( $settings['image_title'] ) && boolval($settings['image_title']) ) {
292
  $uploaded_image['post_title'] = $attachment_title; // Image Title
293
  }
294
+ if ( isset( $settings['image_caption'] ) && boolval($settings['image_caption']) ) {
295
  $uploaded_image['post_excerpt'] = $attachment_title; // Image Caption
296
  }
297
+ if ( isset( $settings['image_description'] ) && boolval($settings['image_description']) ) {
298
  $uploaded_image['post_content'] = $attachment_title; // Image Description
299
  }
300
+ if ( isset( $settings['image_alttext'] ) && boolval($settings['image_alttext']) ) {
301
  update_post_meta( $post_ID, '_wp_attachment_image_alt', $attachment_title ); // Image Alt Text
302
  }
303
 
331
 
332
  // Process the image name and neatify it
333
  $image_name = str_replace( '-', ' ', $image_name ); // replace hyphens with spaces
334
+ $image_name = str_replace( '_', ' ', $image_name ); // replace underscores with spaces
335
  $image_name = ucwords( $image_name ); // Capitalize each word
336
 
337
  // Update the image Title, Caption and Description with the image name
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === Auto Image Attributes From Filename With Bulk Updater ===
2
  Contributors: arunbasillal
3
  Donate link: http://millionclues.com/donate/
4
- Tags: image title, image caption, image description, alt text, bulk edit images, bulk rename images, image attributes
5
  Requires at least: 3.0
6
  Tested up to: 4.8
7
  Stable tag: trunk
@@ -16,7 +16,22 @@ Automatically add Image attributes such as Image Title, Image Caption, Descripti
16
 
17
  The plugin can update image attributes for both new images and existing images in the media library.
18
 
19
- If your image filename is *my-image-name.jpg*, your Image Title, Caption, Description And Alt Text will be *My Image Name*.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  The plugin settings and bulk updater are in WordPress Admin > Settings > Image Attributes. Here you can choose which attributes to update for NEW uploads.
22
 
@@ -46,16 +61,24 @@ Yes! Please [get in touch via my contact form](http://millionclues.com/contact/)
46
 
47
  == Changelog ==
48
 
49
- = 1.0 =
50
- * First release of the plugin.
 
51
 
52
  = 1.1 =
53
- * Added options to choose individual image attributes for NEW uploads.
54
-
55
- == Upgrade Notice ==
56
 
57
  = 1.0 =
58
  * First release of the plugin.
59
 
 
 
 
 
 
 
 
 
 
60
  = 1.0 =
61
- * New feature. Now you can choose specific image attributes for NEW uploads.
1
  === Auto Image Attributes From Filename With Bulk Updater ===
2
  Contributors: arunbasillal
3
  Donate link: http://millionclues.com/donate/
4
+ Tags: image title, image caption, image description, alt text, bulk edit images, bulk rename images, auto image attributes, auto image alt text, remove underscores
5
  Requires at least: 3.0
6
  Tested up to: 4.8
7
  Stable tag: trunk
16
 
17
  The plugin can update image attributes for both new images and existing images in the media library.
18
 
19
+ With this plugin you can:
20
+
21
+ * Set the image filename as the image Title.
22
+ * Set the image filename as the image Caption.
23
+ * Set the image filename as the image Description.
24
+ * Set the image filename as the image Alt Text.
25
+ * Remove hyphens from the image filename.
26
+ * Remove underscores from the image filename.
27
+ * Choose to turn off any of the above mentioned features.
28
+
29
+ With the bulk updater you can:
30
+
31
+ * Set the image filename as image Title, Caption, Description and Alt Text after removing hyphens and underscores from the filename.
32
+ * Update any number of images in your Media Library in one click.
33
+
34
+ If your image filename is *my_image-name.jpg*, your Image Title, Caption, Description And Alt Text will be *My Image Name*.
35
 
36
  The plugin settings and bulk updater are in WordPress Admin > Settings > Image Attributes. Here you can choose which attributes to update for NEW uploads.
37
 
61
 
62
  == Changelog ==
63
 
64
+ = 1.2 =
65
+ * Added: Character filter options. Plugin now removes hyphens and underscores.
66
+ * Bug Fix: Minor bug fix.
67
 
68
  = 1.1 =
69
+ * Added: Options to choose individual image attributes for NEW uploads.
 
 
70
 
71
  = 1.0 =
72
  * First release of the plugin.
73
 
74
+ == Upgrade Notice ==
75
+
76
+ = 1.2 =
77
+ * Added: Character filter options. Plugin now removes hyphens and underscores.
78
+ * Bug Fix: Minor bug fix.
79
+
80
+ = 1.1 =
81
+ * Added: Options to choose individual image attributes for NEW uploads.
82
+
83
  = 1.0 =
84
+ * First release of the plugin.