Clean Image Filenames - Version 1.2.1

Version Description

  • Enable plugin to be translated/internationalization.
Download this release

Release Info

Developer Upperdog
Plugin Icon wp plugin Clean Image Filenames
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2 to 1.2.1

Files changed (2) hide show
  1. clean-image-filenames.php +22 -9
  2. readme.txt +8 -3
clean-image-filenames.php CHANGED
@@ -2,10 +2,12 @@
2
  /**
3
  * Plugin Name: Clean Image Filenames
4
  * Description: Filenames with special characters or language accent characters can sometimes be a problem. This plugin takes care of that by cleaning the filenames.
5
- * Version: 1.2
6
  * Author: Upperdog
7
- * Author URI: http://upperdog.com
8
  * Author Email: hello@upperdog.com
 
 
9
  * License: GPL2
10
  */
11
 
@@ -117,7 +119,7 @@ class CleanImageFilenames {
117
  function admin_init() {
118
 
119
  // Load plugin translations
120
- load_plugin_textdomain( 'clean_image_filenames', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
121
 
122
  // Add settings section
123
  add_settings_section( 'clean_image_filenames_settings_section', 'Clean Image Filenames', array( $this, 'clean_image_filenames_settings_section_callback' ), 'media' );
@@ -125,7 +127,7 @@ class CleanImageFilenames {
125
  // Add settings field
126
  add_settings_field(
127
  'clean_image_filenames_mime_types',
128
- __( 'File types', 'clean_image_filenames' ),
129
  array( $this, 'clean_image_filenames_mime_types_callback' ),
130
  'media',
131
  'clean_image_filenames_settings_section',
@@ -133,11 +135,11 @@ class CleanImageFilenames {
133
  'alternatives' => array(
134
  array(
135
  'value' => 'all',
136
- 'label' => __( 'All file types', 'clean_image_filenames' )
137
  ),
138
  array(
139
  'value' => 'images',
140
- 'label' => __( 'Images only', 'clean_image_filenames' )
141
  )
142
  )
143
  )
@@ -165,7 +167,7 @@ class CleanImageFilenames {
165
  * @since 1.1
166
  */
167
  function clean_image_filenames_settings_section_callback() {
168
- echo '<p>' . __( 'Choose which file types that Clean Image Filenames shall improve the filenames for when files are uploaded.', 'clean_image_filenames' ) . '</p>';
169
  }
170
 
171
  /**
@@ -185,7 +187,7 @@ class CleanImageFilenames {
185
  if ( apply_filters( 'clean_image_filenames_mime_types', $this->plugin_settings[ 'default_mime_types' ] ) !== $this->plugin_settings[ 'default_mime_types' ] ) {
186
 
187
  echo '<input name="clean_image_filenames_mime_types" id="clean_image_filenames_mime_types" type="hidden" value="' . get_option( 'clean_image_filenames_mime_types' ) . '">';
188
- echo '<i>' . __( 'The setting for what file types should be cleaned is disabled since a plugin or theme has already defined what file types should be cleaned.', 'clean_image_filenames' ) . '</i>';
189
 
190
  } else {
191
 
@@ -250,9 +252,20 @@ class CleanImageFilenames {
250
  * @return array The $file array with cleaned filename.
251
  */
252
  function clean_filename( $file ) {
253
-
 
 
 
 
 
 
 
 
 
 
254
  $path = pathinfo( $file[ 'name' ] );
255
  $new_filename = preg_replace( '/.' . $path[ 'extension' ] . '$/', '', $file[ 'name' ] );
 
256
  $file[ 'name' ] = sanitize_title( $new_filename ) . '.' . $path[ 'extension' ];
257
 
258
  return $file;
2
  /**
3
  * Plugin Name: Clean Image Filenames
4
  * Description: Filenames with special characters or language accent characters can sometimes be a problem. This plugin takes care of that by cleaning the filenames.
5
+ * Version: 1.2.1
6
  * Author: Upperdog
7
+ * Author URI: https://upperdog.com
8
  * Author Email: hello@upperdog.com
9
+ * Text Domain: clean-image-filenames
10
+ * Domain Path: /languages
11
  * License: GPL2
12
  */
13
 
119
  function admin_init() {
120
 
121
  // Load plugin translations
122
+ load_plugin_textdomain( 'clean-image-filenames', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
123
 
124
  // Add settings section
125
  add_settings_section( 'clean_image_filenames_settings_section', 'Clean Image Filenames', array( $this, 'clean_image_filenames_settings_section_callback' ), 'media' );
127
  // Add settings field
128
  add_settings_field(
129
  'clean_image_filenames_mime_types',
130
+ __( 'File types', 'clean-image-filenames' ),
131
  array( $this, 'clean_image_filenames_mime_types_callback' ),
132
  'media',
133
  'clean_image_filenames_settings_section',
135
  'alternatives' => array(
136
  array(
137
  'value' => 'all',
138
+ 'label' => __( 'All file types', 'clean-image-filenames' )
139
  ),
140
  array(
141
  'value' => 'images',
142
+ 'label' => __( 'Images only', 'clean-image-filenames' )
143
  )
144
  )
145
  )
167
  * @since 1.1
168
  */
169
  function clean_image_filenames_settings_section_callback() {
170
+ echo '<p>' . __( 'Choose which file types that Clean Image Filenames shall improve the filenames for when files are uploaded.', 'clean-image-filenames' ) . '</p>';
171
  }
172
 
173
  /**
187
  if ( apply_filters( 'clean_image_filenames_mime_types', $this->plugin_settings[ 'default_mime_types' ] ) !== $this->plugin_settings[ 'default_mime_types' ] ) {
188
 
189
  echo '<input name="clean_image_filenames_mime_types" id="clean_image_filenames_mime_types" type="hidden" value="' . get_option( 'clean_image_filenames_mime_types' ) . '">';
190
+ echo '<i>' . __( 'The setting for what file types should be cleaned is disabled since a plugin or theme has already defined what file types should be cleaned.', 'clean-image-filenames' ) . '</i>';
191
 
192
  } else {
193
 
252
  * @return array The $file array with cleaned filename.
253
  */
254
  function clean_filename( $file ) {
255
+
256
+ $input = array(
257
+ 'ß',
258
+ '·',
259
+ );
260
+
261
+ $output = array(
262
+ 'ss',
263
+ '.'
264
+ );
265
+
266
  $path = pathinfo( $file[ 'name' ] );
267
  $new_filename = preg_replace( '/.' . $path[ 'extension' ] . '$/', '', $file[ 'name' ] );
268
+ $new_filename = str_replace( $input, $output, $new_filename );
269
  $file[ 'name' ] = sanitize_title( $new_filename ) . '.' . $path[ 'extension' ];
270
 
271
  return $file;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Upperdog, Gesen
3
  Tags: upload, images, files, media,
4
  Requires at least: 2.9
5
  Tested up to: 4.9.4
6
- Stable tag: 1.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RDLVEE9A2LMUL
@@ -20,10 +20,11 @@ Easily set the plugin to clean the filenames of images only or all files uploade
20
 
21
  = Features =
22
 
23
- * Can be used for all file types, only image file types, or only specific file types
24
- * Is multisite compatible
25
  * Works with custom upload_dir setups
26
  * Doesn't alter your database or uploads settings
 
27
 
28
  = Plugin filter for developers =
29
 
@@ -62,6 +63,10 @@ No, this plugin only cleans the filenames of files when they are being uploaded
62
 
63
  == Changelog ==
64
 
 
 
 
 
65
  = 1.2 =
66
 
67
  * Set original, un-cleaned filename as attachment title.
3
  Tags: upload, images, files, media,
4
  Requires at least: 2.9
5
  Tested up to: 4.9.4
6
+ Stable tag: 1.2.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RDLVEE9A2LMUL
20
 
21
  = Features =
22
 
23
+ * Can be used for all file types, not only images
24
+ * Multisite compatible
25
  * Works with custom upload_dir setups
26
  * Doesn't alter your database or uploads settings
27
+ * Gutenberg ready
28
 
29
  = Plugin filter for developers =
30
 
63
 
64
  == Changelog ==
65
 
66
+ = 1.2.1 =
67
+
68
+ * Enable plugin to be translated/internationalization.
69
+
70
  = 1.2 =
71
 
72
  * Set original, un-cleaned filename as attachment title.