Version Description
- First release of the plugin.
=
Download this release
Release Info
Developer | arunbasillal |
Plugin | Auto Image Attributes From Filename With Bulk Updater (Add Alt Text, Image Title For Image SEO) |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- iaff_image-attributes-from-filename.php +389 -0
- license.txt +281 -0
- readme.txt +51 -0
iaff_image-attributes-from-filename.php
ADDED
@@ -0,0 +1,389 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Auto Image Attributes From Filename With Bulk Updater
|
4 |
+
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.0
|
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
|
12 |
+
*/
|
13 |
+
|
14 |
+
|
15 |
+
/*------------------------------------------*/
|
16 |
+
/* Plugin Setup Functions */
|
17 |
+
/*------------------------------------------*/
|
18 |
+
|
19 |
+
// Exit If Accessed Directly
|
20 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
21 |
+
|
22 |
+
|
23 |
+
// Add Admin Menu Pages
|
24 |
+
// Refer: https://developer.wordpress.org/plugins/administration-menus/
|
25 |
+
function iaff_add_menu_links() {
|
26 |
+
add_options_page( __('Auto Image Attributes','abl_iaff_td'), __('Image Attributes','abl_iaff_td'), 'manage_options', 'image-attributes-from-filename','iaff_admin_interface_render' );
|
27 |
+
}
|
28 |
+
add_action( 'admin_menu', 'iaff_add_menu_links' );
|
29 |
+
|
30 |
+
|
31 |
+
// Print Direct Link To Plugin Settings In Plugins List In Admin
|
32 |
+
function iaff_settings_link( $links ) {
|
33 |
+
return array_merge(
|
34 |
+
array(
|
35 |
+
'settings' => '<a href="' . admin_url( 'options-general.php?page=image-attributes-from-filename' ) . '">' . __( 'Settings', 'abl_iaff_td' ) . '</a>'
|
36 |
+
),
|
37 |
+
$links
|
38 |
+
);
|
39 |
+
}
|
40 |
+
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'iaff_settings_link' );
|
41 |
+
|
42 |
+
|
43 |
+
// Add Donate Link to Plugins list
|
44 |
+
function iaff_plugin_row_meta( $links, $file ) {
|
45 |
+
if ( strpos( $file, 'iaff_image-attributes-from-filename.php' ) !== false ) {
|
46 |
+
$new_links = array(
|
47 |
+
'donate' => '<a href="http://millionclues.com/donate/" target="_blank">Donate</a>',
|
48 |
+
'kuttappi' => '<a href="http://kuttappi.com/" target="_blank">My Travelogue</a>',
|
49 |
+
);
|
50 |
+
$links = array_merge( $links, $new_links );
|
51 |
+
}
|
52 |
+
return $links;
|
53 |
+
}
|
54 |
+
add_filter( 'plugin_row_meta', 'iaff_plugin_row_meta', 10, 2 );
|
55 |
+
|
56 |
+
|
57 |
+
// Load Text Domain
|
58 |
+
function iaff_load_plugin_textdomain() {
|
59 |
+
load_plugin_textdomain( 'abl_iaff_td', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
|
60 |
+
}
|
61 |
+
add_action( 'plugins_loaded', 'iaff_load_plugin_textdomain' );
|
62 |
+
|
63 |
+
|
64 |
+
// Do Stuff On Plugin Activation
|
65 |
+
function iaff_activate_plugin() {
|
66 |
+
add_option( 'iaff_image_attributes_from_filename_settings', '1' ); // Setting default value. 1 = enable Auto Image Attributes for new images on plugin install
|
67 |
+
add_option( 'iaff_bulk_updater_counter', '0' ); // Setting numer of images processed as zero
|
68 |
+
}
|
69 |
+
register_activation_hook( __FILE__, 'iaff_activate_plugin' );
|
70 |
+
|
71 |
+
|
72 |
+
// Register Settings
|
73 |
+
function iaff_register_settings() {
|
74 |
+
|
75 |
+
// Register Setting
|
76 |
+
register_setting( 'iaff_image_attributes_from_filename_settings_group', 'iaff_image_attributes_from_filename_settings', 'boolval' );
|
77 |
+
|
78 |
+
// Register A New Section
|
79 |
+
add_settings_section(
|
80 |
+
'iaff_auto_image_attributes_settings', // ID
|
81 |
+
__('Auto Image Attributes', 'abl_iaff_td'), // Title
|
82 |
+
'iaff_auto_image_attributes_callback', // Callback Function
|
83 |
+
'image-attributes-from-filename' // Page slug
|
84 |
+
);
|
85 |
+
|
86 |
+
// Register a new field in the "iaff_auto_image_attributes_settings" section, inside the "image-attributes-from-filename" page
|
87 |
+
add_settings_field(
|
88 |
+
'iaff_auto_image_attributes_settings_field', // ID
|
89 |
+
__('Auto Image Attributes Setting', 'abl_iaff_td'), // Title
|
90 |
+
'iaff_auto_image_attributes_settings_field_callback', // Callback function
|
91 |
+
'image-attributes-from-filename', // Page slug
|
92 |
+
'iaff_auto_image_attributes_settings' // Settings Section ID
|
93 |
+
);
|
94 |
+
}
|
95 |
+
add_action( 'admin_init', 'iaff_register_settings' );
|
96 |
+
|
97 |
+
|
98 |
+
// Do Stuff On Plugin Uninstall
|
99 |
+
function iaff_uninstall_plugin() {
|
100 |
+
delete_option( 'iaff_image_attributes_from_filename_settings' );
|
101 |
+
delete_option( 'iaff_bulk_updater_counter' );
|
102 |
+
}
|
103 |
+
register_uninstall_hook(__FILE__, 'iaff_uninstall_plugin' );
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
/*--------------------------------------*/
|
108 |
+
/* Admin Options Page */
|
109 |
+
/*--------------------------------------*/
|
110 |
+
|
111 |
+
function iaff_auto_image_attributes_callback()
|
112 |
+
{
|
113 |
+
echo '<p>' . __('Enable this to automatically add Image Caption, Description and Alt Text from image title for new uploads.', 'abl_iaff_td') . '</p>';
|
114 |
+
}
|
115 |
+
|
116 |
+
// field content cb
|
117 |
+
function iaff_auto_image_attributes_settings_field_callback()
|
118 |
+
{
|
119 |
+
// Get the value of the setting we've registered with register_setting()
|
120 |
+
$setting = get_option('iaff_image_attributes_from_filename_settings');
|
121 |
+
|
122 |
+
// Output the field
|
123 |
+
// ID and name of form element should be same as the setting name. ?>
|
124 |
+
<input type="checkbox" name="iaff_image_attributes_from_filename_settings" id="iaff_image_attributes_from_filename_settings" value="Enable Auto Image Attributes" <?php echo boolval($setting) ? 'checked' : '';?>><label for="iaff_image_attributes_from_filename_settings"><?php _e('Enable Auto Image Attributes', 'abl_iaff_td') ?></label>
|
125 |
+
|
126 |
+
<?php
|
127 |
+
}
|
128 |
+
|
129 |
+
// Admin Interface Renderer
|
130 |
+
function iaff_admin_interface_render () {
|
131 |
+
|
132 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
133 |
+
return;
|
134 |
+
}
|
135 |
+
|
136 |
+
/* Commented out after moving menu location to Settings pages instead of Media as originally deisigned.
|
137 |
+
// https://core.trac.wordpress.org/ticket/31000
|
138 |
+
// Check if the user have submitted the settings
|
139 |
+
// WordPress will add the "settings-updated" $_GET parameter to the url
|
140 |
+
if ( isset( $_GET['settings-updated'] ) ) {
|
141 |
+
// Add settings saved message with the class of "updated"
|
142 |
+
add_settings_error( 'iaff_settings_saved_message', 'iaff_settings_saved_message', __( 'Settings are Saved', 'abl_iaff_td' ), 'updated' );
|
143 |
+
}
|
144 |
+
|
145 |
+
// Show Settings Saved Message
|
146 |
+
settings_errors( 'iaff_settings_saved_message' ); */?>
|
147 |
+
|
148 |
+
<div class="wrap">
|
149 |
+
<h1>Auto Image Attributes From Filename With Bulk Updater</h1>
|
150 |
+
|
151 |
+
<form action="options.php" method="post">
|
152 |
+
<?php
|
153 |
+
// Output nonce, action, and option_page fields for a settings page.
|
154 |
+
settings_fields( 'iaff_image_attributes_from_filename_settings_group' );
|
155 |
+
|
156 |
+
// Prints out all settings sections added to a particular settings page.
|
157 |
+
do_settings_sections( 'image-attributes-from-filename' ); // Page slug
|
158 |
+
|
159 |
+
// Output save settings button
|
160 |
+
submit_button( __('Save Settings', 'abl_iaff_td') );
|
161 |
+
?>
|
162 |
+
</form>
|
163 |
+
|
164 |
+
<h2><?php _e('Update Existing Images In Media Library', 'abl_iaff_td') ?></h2>
|
165 |
+
|
166 |
+
<p style="color:red"><?php _e('IMPORTANT: Please backup your database before running the bulk updater.', 'abl_iaff_td') ?></p>
|
167 |
+
<p><?php _e('Run this bulk updater to update Image Title, Caption, Description and Alt Text from image filename for existing images in the media library.', 'abl_iaff_td') ?></p>
|
168 |
+
<p><?php _e('If your image is named a-lot-like-love.jpg, your Image Title, Caption, Description and Alt Text will be: A Lot Like Love.', 'abl_iaff_td') ?></p>
|
169 |
+
<p><?php _e('Do not close the browser while it\'s running. In case you do, you can always resume by returning to this page later.', 'abl_iaff_td') ?></p> <?php
|
170 |
+
|
171 |
+
submit_button( __('Run Bulk Updater', 'abl_iaff_td'), 'iaff_run_bulk_updater_button' ); ?>
|
172 |
+
|
173 |
+
<p><?php _e('To restart processing images from the beginning (the oldest upload first), reset the counter.', 'abl_iaff_td') ?></p> <?php
|
174 |
+
submit_button( __('Reset Counter', 'abl_iaff_td'), 'iaff_reset_counter_button' ); ?>
|
175 |
+
|
176 |
+
<p><?php _e('Number of Images Updated: ', 'abl_iaff_td') ?><span id="iaff_updated_counter"><?php iaff_number_of_images_updated(); ?></span></p>
|
177 |
+
<p id="iaff_remaining_images_text" style="display: none;"><?php _e('Number of Images Remaining: ', 'abl_iaff_td') ?><span id="iaff_remaining_counter"><?php echo iaff_total_number_of_images(); ?></span></p>
|
178 |
+
|
179 |
+
<span id="iaff_bulk_updater_results"></span>
|
180 |
+
|
181 |
+
</div>
|
182 |
+
<?php
|
183 |
+
}
|
184 |
+
|
185 |
+
|
186 |
+
|
187 |
+
/*--------------------------------------*/
|
188 |
+
/* Plugin Operations */
|
189 |
+
/*--------------------------------------*/
|
190 |
+
|
191 |
+
|
192 |
+
// Auto Add Image Attributes From Image Filename
|
193 |
+
function iaff_auto_image_attributes( $post_ID ) {
|
194 |
+
|
195 |
+
// Check if Auto Image Attributes is enabled
|
196 |
+
$setting = get_option('iaff_image_attributes_from_filename_settings');
|
197 |
+
if ( ! boolval($setting) ) {
|
198 |
+
return;
|
199 |
+
}
|
200 |
+
|
201 |
+
$attachment = get_post( $post_ID );
|
202 |
+
$attachment_title = $attachment->post_title;
|
203 |
+
|
204 |
+
$attachment_title = str_replace( '-', ' ', $attachment_title ); // Hyphen Removal
|
205 |
+
$attachment_title = ucwords( $attachment_title ); // Capitalize First Word
|
206 |
+
|
207 |
+
$uploaded_image = array();
|
208 |
+
$uploaded_image['ID'] = $post_ID;
|
209 |
+
$uploaded_image['post_title'] = $attachment_title; // Image Title
|
210 |
+
$uploaded_image['post_excerpt'] = $attachment_title; // Image Caption
|
211 |
+
$uploaded_image['post_content'] = $attachment_title; // Image Description
|
212 |
+
|
213 |
+
update_post_meta( $post_ID, '_wp_attachment_image_alt', $attachment_title ); // Image Alt Text
|
214 |
+
|
215 |
+
wp_update_post( $uploaded_image );
|
216 |
+
|
217 |
+
}
|
218 |
+
add_action( 'add_attachment', 'iaff_auto_image_attributes' );
|
219 |
+
|
220 |
+
|
221 |
+
// Auto Add Image Attributes From Image Filename For Existing Uploads
|
222 |
+
function iaff_rename_old_image() {
|
223 |
+
|
224 |
+
// Security Check
|
225 |
+
check_ajax_referer( 'iaff_rename_old_image_nonce', 'security' );
|
226 |
+
|
227 |
+
// Retrieve Counter
|
228 |
+
$counter = get_option('iaff_bulk_updater_counter');
|
229 |
+
$counter = intval ($counter);
|
230 |
+
|
231 |
+
global $wpdb;
|
232 |
+
$image = $wpdb->get_row("SELECT ID,guid FROM {$wpdb->prefix}posts WHERE post_type='attachment' ORDER BY post_date LIMIT 1 OFFSET {$counter}");
|
233 |
+
|
234 |
+
// Die If No Image
|
235 |
+
if ($image === NULL) {
|
236 |
+
wp_die();
|
237 |
+
}
|
238 |
+
|
239 |
+
// Extract the image name from the image url
|
240 |
+
$image_extension = pathinfo($image->guid);
|
241 |
+
$image_name = basename($image->guid, '.'.$image_extension['extension']);
|
242 |
+
|
243 |
+
// Process the image name and neatify it
|
244 |
+
$image_name = str_replace( '-', ' ', $image_name ); // replace hyphens with spaces
|
245 |
+
$image_name = ucwords( $image_name ); // Capitalize each word
|
246 |
+
|
247 |
+
// Update the image Title, Caption and Description with the image name
|
248 |
+
$updated_image = array(
|
249 |
+
'ID' => $image->ID,
|
250 |
+
'post_title' => $image_name, // Image Title
|
251 |
+
'post_excerpt' => $image_name, // Image Caption
|
252 |
+
'post_content' => $image_name, // Image Description
|
253 |
+
);
|
254 |
+
wp_update_post( $updated_image );
|
255 |
+
|
256 |
+
// Update Image Alt Text (stored in post_meta table)
|
257 |
+
update_post_meta( $image->ID, '_wp_attachment_image_alt', $image_name ); // Image Alt Text
|
258 |
+
|
259 |
+
// Increment Counter And Update It
|
260 |
+
$counter++;
|
261 |
+
update_option( 'iaff_bulk_updater_counter', $counter );
|
262 |
+
|
263 |
+
echo __('Image Attributes Updated For Image: ', 'abl_iaff_td') . $image->guid;
|
264 |
+
wp_die();
|
265 |
+
}
|
266 |
+
add_action( 'wp_ajax_iaff_rename_old_image', 'iaff_rename_old_image' );
|
267 |
+
|
268 |
+
|
269 |
+
// Print Number Of Images Updated By The Bulk Updater
|
270 |
+
function iaff_number_of_images_updated() {
|
271 |
+
|
272 |
+
$iaff_images_updated_counter = get_option('iaff_bulk_updater_counter');
|
273 |
+
echo $iaff_images_updated_counter;
|
274 |
+
}
|
275 |
+
|
276 |
+
|
277 |
+
// Count Total Number Of Images In The Database
|
278 |
+
function iaff_total_number_of_images() {
|
279 |
+
|
280 |
+
global $wpdb;
|
281 |
+
$total_no_of_images = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->prefix}posts WHERE post_type='attachment'");
|
282 |
+
|
283 |
+
return $total_no_of_images;
|
284 |
+
}
|
285 |
+
|
286 |
+
// Count Remaining Number Of Images To Process
|
287 |
+
function iaff_count_remaining_images() {
|
288 |
+
|
289 |
+
$total_no_of_images = iaff_total_number_of_images();
|
290 |
+
|
291 |
+
$no_of_images_processed = get_option('iaff_bulk_updater_counter');
|
292 |
+
$no_of_images_processed = intval ($no_of_images_processed);
|
293 |
+
|
294 |
+
$reamining_images = $total_no_of_images - $no_of_images_processed;
|
295 |
+
echo $reamining_images;
|
296 |
+
|
297 |
+
wp_die();
|
298 |
+
}
|
299 |
+
add_action( 'wp_ajax_iaff_count_remaining_images', 'iaff_count_remaining_images' );
|
300 |
+
|
301 |
+
|
302 |
+
// Reset Counter To Zero So That Bulk Updating Starts From Scratch
|
303 |
+
function iaff_reset_bulk_updater_counter() {
|
304 |
+
|
305 |
+
// Security Check
|
306 |
+
check_ajax_referer( 'iaff_reset_counter_nonce', 'security' );
|
307 |
+
|
308 |
+
update_option( 'iaff_bulk_updater_counter', '0' );
|
309 |
+
echo __('Counter reset. The bulk updater will start from scratch in the next run.', 'abl_iaff_td');
|
310 |
+
|
311 |
+
wp_die();
|
312 |
+
}
|
313 |
+
add_action( 'wp_ajax_iaff_reset_bulk_updater_counter', 'iaff_reset_bulk_updater_counter' );
|
314 |
+
|
315 |
+
|
316 |
+
// Bulk Updater Ajax
|
317 |
+
function iaff_image_bulk_updater() {
|
318 |
+
|
319 |
+
// Load Ajax Only On Plugin Page
|
320 |
+
$screen = get_current_screen();
|
321 |
+
if ( $screen->id !== "settings_page_image-attributes-from-filename" ) {
|
322 |
+
return;
|
323 |
+
}?>
|
324 |
+
|
325 |
+
<script type="text/javascript" >
|
326 |
+
jQuery(document).ready(function($) {
|
327 |
+
// Reset Bulk Updater Counter
|
328 |
+
$('.iaff_reset_counter_button').click(function() {
|
329 |
+
data = {
|
330 |
+
action: 'iaff_reset_bulk_updater_counter',
|
331 |
+
security: '<?php echo wp_create_nonce( "iaff_reset_counter_nonce" ); ?>'
|
332 |
+
};
|
333 |
+
|
334 |
+
$.post(ajaxurl, data, function (response) {
|
335 |
+
alert(response);
|
336 |
+
$('#iaff_updated_counter').text('0');
|
337 |
+
});
|
338 |
+
});
|
339 |
+
|
340 |
+
// Run Bulk Updater
|
341 |
+
$('.iaff_run_bulk_updater_button').click(function() {
|
342 |
+
// Count Remaining Images To Process
|
343 |
+
data = {
|
344 |
+
action: 'iaff_count_remaining_images'
|
345 |
+
};
|
346 |
+
|
347 |
+
var remaining_images = null;
|
348 |
+
|
349 |
+
var reamining_images_count = $.post(ajaxurl, data, function (response) {
|
350 |
+
remaining_images = response;
|
351 |
+
console.log(remaining_images);
|
352 |
+
});
|
353 |
+
|
354 |
+
// Loop For Each Image And Update Its Attributes
|
355 |
+
reamining_images_count.done(function iaff_rename_image() {
|
356 |
+
|
357 |
+
if(remaining_images > 0){
|
358 |
+
|
359 |
+
$('#iaff_remaining_images_text').show(); // Show the text for remaining images
|
360 |
+
|
361 |
+
data = {
|
362 |
+
action: 'iaff_rename_old_image',
|
363 |
+
security: '<?php echo wp_create_nonce( "iaff_rename_old_image_nonce" ); ?>'
|
364 |
+
};
|
365 |
+
|
366 |
+
var rename_image = $.post(ajaxurl, data, function (response) {
|
367 |
+
$('#iaff_bulk_updater_results').append('<p>' + response + '</p>');
|
368 |
+
var updated_counter = parseInt($('#iaff_updated_counter').text());
|
369 |
+
$('#iaff_updated_counter').text(updated_counter+1); // Update total number of images updated
|
370 |
+
$('#iaff_remaining_counter').text(remaining_images-1); // Update total number of images remaining
|
371 |
+
console.log(response);
|
372 |
+
});
|
373 |
+
|
374 |
+
rename_image.done(function() {
|
375 |
+
remaining_images--;
|
376 |
+
iaff_rename_image();
|
377 |
+
});
|
378 |
+
}
|
379 |
+
else {
|
380 |
+
$('#iaff_bulk_updater_results').append('<p>All done!</p>')
|
381 |
+
$('#iaff_remaining_counter').text('All done!')
|
382 |
+
}
|
383 |
+
});
|
384 |
+
});
|
385 |
+
});
|
386 |
+
</script> <?php
|
387 |
+
}
|
388 |
+
add_action( 'admin_footer', 'iaff_image_bulk_updater' );
|
389 |
+
?>
|
license.txt
ADDED
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
5 |
+
51 Franklin St, Fifth Floor, Boston, MA 02110, USA
|
6 |
+
|
7 |
+
Everyone is permitted to copy and distribute verbatim copies
|
8 |
+
of this license document, but changing it is not allowed.
|
9 |
+
|
10 |
+
Preamble
|
11 |
+
|
12 |
+
The licenses for most software are designed to take away your
|
13 |
+
freedom to share and change it. By contrast, the GNU General Public
|
14 |
+
License is intended to guarantee your freedom to share and change free
|
15 |
+
software--to make sure the software is free for all its users. This
|
16 |
+
General Public License applies to most of the Free Software
|
17 |
+
Foundation's software and to any other program whose authors commit to
|
18 |
+
using it. (Some other Free Software Foundation software is covered by
|
19 |
+
the GNU Library General Public License instead.) You can apply it to
|
20 |
+
your programs, too.
|
21 |
+
|
22 |
+
When we speak of free software, we are referring to freedom, not
|
23 |
+
price. Our General Public Licenses are designed to make sure that you
|
24 |
+
have the freedom to distribute copies of free software (and charge for
|
25 |
+
this service if you wish), that you receive source code or can get it
|
26 |
+
if you want it, that you can change the software or use pieces of it
|
27 |
+
in new free programs; and that you know you can do these things.
|
28 |
+
|
29 |
+
To protect your rights, we need to make restrictions that forbid
|
30 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
31 |
+
These restrictions translate to certain responsibilities for you if you
|
32 |
+
distribute copies of the software, or if you modify it.
|
33 |
+
|
34 |
+
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must give the recipients all the rights that
|
36 |
+
you have. You must make sure that they, too, receive or can get the
|
37 |
+
source code. And you must show them these terms so they know their
|
38 |
+
rights.
|
39 |
+
|
40 |
+
We protect your rights with two steps: (1) copyright the software, and
|
41 |
+
(2) offer you this license which gives you legal permission to copy,
|
42 |
+
distribute and/or modify the software.
|
43 |
+
|
44 |
+
Also, for each author's protection and ours, we want to make certain
|
45 |
+
that everyone understands that there is no warranty for this free
|
46 |
+
software. If the software is modified by someone else and passed on, we
|
47 |
+
want its recipients to know that what they have is not the original, so
|
48 |
+
that any problems introduced by others will not reflect on the original
|
49 |
+
authors' reputations.
|
50 |
+
|
51 |
+
Finally, any free program is threatened constantly by software
|
52 |
+
patents. We wish to avoid the danger that redistributors of a free
|
53 |
+
program will individually obtain patent licenses, in effect making the
|
54 |
+
program proprietary. To prevent this, we have made it clear that any
|
55 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
56 |
+
|
57 |
+
The precise terms and conditions for copying, distribution and
|
58 |
+
modification follow.
|
59 |
+
|
60 |
+
GNU GENERAL PUBLIC LICENSE
|
61 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
62 |
+
|
63 |
+
0. This License applies to any program or other work which contains
|
64 |
+
a notice placed by the copyright holder saying it may be distributed
|
65 |
+
under the terms of this General Public License. The "Program", below,
|
66 |
+
refers to any such program or work, and a "work based on the Program"
|
67 |
+
means either the Program or any derivative work under copyright law:
|
68 |
+
that is to say, a work containing the Program or a portion of it,
|
69 |
+
either verbatim or with modifications and/or translated into another
|
70 |
+
language. (Hereinafter, translation is included without limitation in
|
71 |
+
the term "modification".) Each licensee is addressed as "you".
|
72 |
+
|
73 |
+
Activities other than copying, distribution and modification are not
|
74 |
+
covered by this License; they are outside its scope. The act of
|
75 |
+
running the Program is not restricted, and the output from the Program
|
76 |
+
is covered only if its contents constitute a work based on the
|
77 |
+
Program (independent of having been made by running the Program).
|
78 |
+
Whether that is true depends on what the Program does.
|
79 |
+
|
80 |
+
1. You may copy and distribute verbatim copies of the Program's
|
81 |
+
source code as you receive it, in any medium, provided that you
|
82 |
+
conspicuously and appropriately publish on each copy an appropriate
|
83 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
84 |
+
notices that refer to this License and to the absence of any warranty;
|
85 |
+
and give any other recipients of the Program a copy of this License
|
86 |
+
along with the Program.
|
87 |
+
|
88 |
+
You may charge a fee for the physical act of transferring a copy, and
|
89 |
+
you may at your option offer warranty protection in exchange for a fee.
|
90 |
+
|
91 |
+
2. You may modify your copy or copies of the Program or any portion
|
92 |
+
of it, thus forming a work based on the Program, and copy and
|
93 |
+
distribute such modifications or work under the terms of Section 1
|
94 |
+
above, provided that you also meet all of these conditions:
|
95 |
+
|
96 |
+
a) You must cause the modified files to carry prominent notices
|
97 |
+
stating that you changed the files and the date of any change.
|
98 |
+
|
99 |
+
b) You must cause any work that you distribute or publish, that in
|
100 |
+
whole or in part contains or is derived from the Program or any
|
101 |
+
part thereof, to be licensed as a whole at no charge to all third
|
102 |
+
parties under the terms of this License.
|
103 |
+
|
104 |
+
c) If the modified program normally reads commands interactively
|
105 |
+
when run, you must cause it, when started running for such
|
106 |
+
interactive use in the most ordinary way, to print or display an
|
107 |
+
announcement including an appropriate copyright notice and a
|
108 |
+
notice that there is no warranty (or else, saying that you provide
|
109 |
+
a warranty) and that users may redistribute the program under
|
110 |
+
these conditions, and telling the user how to view a copy of this
|
111 |
+
License. (Exception: if the Program itself is interactive but
|
112 |
+
does not normally print such an announcement, your work based on
|
113 |
+
the Program is not required to print an announcement.)
|
114 |
+
|
115 |
+
These requirements apply to the modified work as a whole. If
|
116 |
+
identifiable sections of that work are not derived from the Program,
|
117 |
+
and can be reasonably considered independent and separate works in
|
118 |
+
themselves, then this License, and its terms, do not apply to those
|
119 |
+
sections when you distribute them as separate works. But when you
|
120 |
+
distribute the same sections as part of a whole which is a work based
|
121 |
+
on the Program, the distribution of the whole must be on the terms of
|
122 |
+
this License, whose permissions for other licensees extend to the
|
123 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
readme.txt
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
Automatically Add Image Title, Caption, Description And Alt Text From Filename. Includes a bulk updater to update existing images in the Media Library
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
Automatically add Image attributes such as Image Title, Image Caption, Description And Alt Text from Image Filename.
|
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 bulk updater and plugin settings in WordPress Admin > Settings > Image Attributes. You can disable auto attributes for new uploads by disabling it in the settings page.
|
22 |
+
|
23 |
+
Please remember to take a database backup before running the bulk updater.
|
24 |
+
|
25 |
+
== Installation ==
|
26 |
+
|
27 |
+
To install this plugin:
|
28 |
+
|
29 |
+
1. Install the plugin through the WordPress admin interface, or upload the plugin folder to /wp-content/plugins/ using ftp.
|
30 |
+
2. Activate the plugin through the 'Plugins' screen in WordPress.
|
31 |
+
3. Go to WordPress Admin > Settings > Image Attributes
|
32 |
+
|
33 |
+
== Frequently Asked Questions ==
|
34 |
+
|
35 |
+
= Will this plugin update existing images in the media library? =
|
36 |
+
|
37 |
+
Yes, the plugin will update Image Title, Caption, Description And Alt Text from the imgage filename for both existing images in the media library and new uploads.
|
38 |
+
|
39 |
+
== Screenshots ==
|
40 |
+
|
41 |
+
1. The settings page in WordPress Admin > Settings > Image Attributes
|
42 |
+
|
43 |
+
== Changelog ==
|
44 |
+
|
45 |
+
= 1.0 =
|
46 |
+
* First release of the plugin.
|
47 |
+
|
48 |
+
== Upgrade Notice ==
|
49 |
+
|
50 |
+
= 1.0 =
|
51 |
+
* First release of the plugin.
|