Categories Images - Version 2.5.2

Version Description

  • Fix displaying full size image bug in backend
  • Fix quick edit bug
  • Some code enhancements
Download this release

Release Info

Developer elzahlan
Plugin Icon 128x128 Categories Images
Version 2.5.2
Comparing to
See all releases

Code changes from version 2.5.1 to 2.5.2

Files changed (2) hide show
  1. categories-images.php +16 -16
  2. readme.txt +6 -1
categories-images.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://zahlan.net/blog/2012/06/categories-images/
5
  * Description: Categories Images Plugin allow you to add an image to category or any custom term.
6
  * Author: Muhammad Said El Zahlan
7
- * Version: 2.5.1
8
  * Author URI: http://zahlan.net/
9
  * Domain Path: /languages
10
  * Text Domain: categories-images
@@ -75,12 +75,12 @@ function z_edit_texonomy_field($taxonomy) {
75
  }
76
 
77
  if (z_taxonomy_image_url( $taxonomy->term_id, NULL, TRUE ) == Z_IMAGE_PLACEHOLDER)
78
- $image_text = "";
79
  else
80
- $image_text = z_taxonomy_image_url( $taxonomy->term_id, NULL, TRUE );
81
  echo '<tr class="form-field">
82
  <th scope="row" valign="top"><label for="taxonomy_image">' . __('Image', 'categories-images') . '</label></th>
83
- <td><img class="taxonomy-image" src="' . z_taxonomy_image_url( $taxonomy->term_id, NULL, TRUE ) . '"/><br/><input type="text" name="taxonomy_image" id="taxonomy_image" value="'.$image_text.'" /><br />
84
  <button class="z_upload_image_button button">' . __('Upload/Add image', 'categories-images') . '</button>
85
  <button class="z_remove_image_button button">' . __('Remove image', 'categories-images') . '</button>
86
  </td>
@@ -122,6 +122,7 @@ function z_script() {
122
  });
123
 
124
  $(".z_remove_image_button").click(function() {
 
125
  $("#taxonomy_image").val("");
126
  $(this).parent().siblings(".title").children("img").attr("src","' . Z_IMAGE_PLACEHOLDER . '");
127
  $(".inline-edit-col :input[name=\'taxonomy_image\']").val("");
@@ -141,17 +142,18 @@ function z_script() {
141
  }
142
  }
143
 
144
- $(".editinline").live("click", function(){
145
  var tax_id = $(this).parents("tr").attr("id").substr(4);
146
  var thumb = $("#tag-"+tax_id+" .thumb img").attr("src");
 
147
  if (thumb != "' . Z_IMAGE_PLACEHOLDER . '") {
148
  $(".inline-edit-col :input[name=\'taxonomy_image\']").val(thumb);
149
  } else {
150
  $(".inline-edit-col :input[name=\'taxonomy_image\']").val("");
151
  }
 
152
  $(".inline-edit-col .title img").attr("src",thumb);
153
- return false;
154
- });
155
  });
156
  </script>';
157
  }
@@ -161,19 +163,19 @@ add_action('edit_term','z_save_taxonomy_image');
161
  add_action('create_term','z_save_taxonomy_image');
162
  function z_save_taxonomy_image($term_id) {
163
  if(isset($_POST['taxonomy_image']))
164
- update_option('z_taxonomy_image'.$term_id, $_POST['taxonomy_image']);
165
  }
166
 
167
  // get attachment ID by image url
168
  function z_get_attachment_id_by_url($image_src) {
169
  global $wpdb;
170
- $query = "SELECT ID FROM {$wpdb->posts} WHERE guid = '$image_src'";
171
  $id = $wpdb->get_var($query);
172
  return (!empty($id)) ? $id : NULL;
173
  }
174
 
175
  // get taxonomy image url for the given term_id (Place holder image by default)
176
- function z_taxonomy_image_url($term_id = NULL, $size = NULL, $return_placeholder = FALSE) {
177
  if (!$term_id) {
178
  if (is_category())
179
  $term_id = get_query_var('cat');
@@ -187,8 +189,6 @@ function z_taxonomy_image_url($term_id = NULL, $size = NULL, $return_placeholder
187
  if(!empty($taxonomy_image_url)) {
188
  $attachment_id = z_get_attachment_id_by_url($taxonomy_image_url);
189
  if(!empty($attachment_id)) {
190
- if (empty($size))
191
- $size = 'full';
192
  $taxonomy_image_url = wp_get_attachment_image_src($attachment_id, $size);
193
  $taxonomy_image_url = $taxonomy_image_url[0];
194
  }
@@ -244,17 +244,17 @@ function z_taxonomy_columns( $columns ) {
244
  */
245
  function z_taxonomy_column( $columns, $column, $id ) {
246
  if ( $column == 'thumb' )
247
- $columns = '<span><img src="' . z_taxonomy_image_url($id, NULL, TRUE) . '" alt="' . __('Thumbnail', 'categories-images') . '" class="wp-post-image" /></span>';
248
 
249
  return $columns;
250
  }
251
 
252
- // change 'insert into post' to 'use this image'
253
  function z_change_insert_button_text($safe_text, $text) {
254
  return str_replace("Insert into Post", "Use this image", $text);
255
  }
256
 
257
- // style the image in category list
258
  if ( strpos( $_SERVER['SCRIPT_NAME'], 'edit-tags.php' ) > 0 ) {
259
  add_action( 'admin_head', 'z_add_style' );
260
  add_action('quick_edit_custom_box', 'z_quick_edit_custom_box', 10, 3);
@@ -312,7 +312,7 @@ function zci_options() {
312
  <?php
313
  }
314
 
315
- // get taxonomy image for the given term_id
316
  function z_taxonomy_image($term_id = NULL, $size = 'full', $attr = NULL, $echo = TRUE) {
317
  if (!$term_id) {
318
  if (is_category())
4
  * Plugin URI: http://zahlan.net/blog/2012/06/categories-images/
5
  * Description: Categories Images Plugin allow you to add an image to category or any custom term.
6
  * Author: Muhammad Said El Zahlan
7
+ * Version: 2.5.2
8
  * Author URI: http://zahlan.net/
9
  * Domain Path: /languages
10
  * Text Domain: categories-images
75
  }
76
 
77
  if (z_taxonomy_image_url( $taxonomy->term_id, NULL, TRUE ) == Z_IMAGE_PLACEHOLDER)
78
+ $image_url = "";
79
  else
80
+ $image_url = z_taxonomy_image_url( $taxonomy->term_id, NULL, TRUE );
81
  echo '<tr class="form-field">
82
  <th scope="row" valign="top"><label for="taxonomy_image">' . __('Image', 'categories-images') . '</label></th>
83
+ <td><img class="taxonomy-image" src="' . z_taxonomy_image_url( $taxonomy->term_id, 'medium', TRUE ) . '"/><br/><input type="text" name="taxonomy_image" id="taxonomy_image" value="'.$image_url.'" /><br />
84
  <button class="z_upload_image_button button">' . __('Upload/Add image', 'categories-images') . '</button>
85
  <button class="z_remove_image_button button">' . __('Remove image', 'categories-images') . '</button>
86
  </td>
122
  });
123
 
124
  $(".z_remove_image_button").click(function() {
125
+ $(".taxonomy-image").attr("src", "'.Z_IMAGE_PLACEHOLDER.'");
126
  $("#taxonomy_image").val("");
127
  $(this).parent().siblings(".title").children("img").attr("src","' . Z_IMAGE_PLACEHOLDER . '");
128
  $(".inline-edit-col :input[name=\'taxonomy_image\']").val("");
142
  }
143
  }
144
 
145
+ $(".editinline").click(function() {
146
  var tax_id = $(this).parents("tr").attr("id").substr(4);
147
  var thumb = $("#tag-"+tax_id+" .thumb img").attr("src");
148
+
149
  if (thumb != "' . Z_IMAGE_PLACEHOLDER . '") {
150
  $(".inline-edit-col :input[name=\'taxonomy_image\']").val(thumb);
151
  } else {
152
  $(".inline-edit-col :input[name=\'taxonomy_image\']").val("");
153
  }
154
+
155
  $(".inline-edit-col .title img").attr("src",thumb);
156
+ });
 
157
  });
158
  </script>';
159
  }
163
  add_action('create_term','z_save_taxonomy_image');
164
  function z_save_taxonomy_image($term_id) {
165
  if(isset($_POST['taxonomy_image']))
166
+ update_option('z_taxonomy_image'.$term_id, $_POST['taxonomy_image'], NULL);
167
  }
168
 
169
  // get attachment ID by image url
170
  function z_get_attachment_id_by_url($image_src) {
171
  global $wpdb;
172
+ $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid = %s", $image_src);
173
  $id = $wpdb->get_var($query);
174
  return (!empty($id)) ? $id : NULL;
175
  }
176
 
177
  // get taxonomy image url for the given term_id (Place holder image by default)
178
+ function z_taxonomy_image_url($term_id = NULL, $size = 'full', $return_placeholder = FALSE) {
179
  if (!$term_id) {
180
  if (is_category())
181
  $term_id = get_query_var('cat');
189
  if(!empty($taxonomy_image_url)) {
190
  $attachment_id = z_get_attachment_id_by_url($taxonomy_image_url);
191
  if(!empty($attachment_id)) {
 
 
192
  $taxonomy_image_url = wp_get_attachment_image_src($attachment_id, $size);
193
  $taxonomy_image_url = $taxonomy_image_url[0];
194
  }
244
  */
245
  function z_taxonomy_column( $columns, $column, $id ) {
246
  if ( $column == 'thumb' )
247
+ $columns = '<span><img src="' . z_taxonomy_image_url($id, 'thumbnail', TRUE) . '" alt="' . __('Thumbnail', 'categories-images') . '" class="wp-post-image" /></span>';
248
 
249
  return $columns;
250
  }
251
 
252
+ // Change 'insert into post' to 'use this image'
253
  function z_change_insert_button_text($safe_text, $text) {
254
  return str_replace("Insert into Post", "Use this image", $text);
255
  }
256
 
257
+ // Style the image in category list
258
  if ( strpos( $_SERVER['SCRIPT_NAME'], 'edit-tags.php' ) > 0 ) {
259
  add_action( 'admin_head', 'z_add_style' );
260
  add_action('quick_edit_custom_box', 'z_quick_edit_custom_box', 10, 3);
312
  <?php
313
  }
314
 
315
+ // display taxonomy image for the given term_id
316
  function z_taxonomy_image($term_id = NULL, $size = 'full', $attr = NULL, $echo = TRUE) {
317
  if (!$term_id) {
318
  if (is_category())
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: Category Image, Category Images, Categories Images, taxonomy image, taxonomy images, taxonomies images, category icon, categories icons, category logo, categories logos, admin, wp-admin, category image plugin, categories images plugin, category featured image, categories featured images, feature image for category
5
  Requires at least: 2.8
6
  Tested up to: 4.3.1
7
- Stable tag: 2.5.1
8
 
9
  The Categories Images Plugin allow you to add image with category or taxonomy.
10
 
@@ -57,6 +57,11 @@ Please check the documentation page:
57
 
58
  == Changelog ==
59
 
 
 
 
 
 
60
  = 2.5.1 =
61
  * Adding language support for Russian.
62
  * Adding language support for Serbian. Thanks to Andrijana Nikolic [http://webhostinggeeks.com/].
4
  Tags: Category Image, Category Images, Categories Images, taxonomy image, taxonomy images, taxonomies images, category icon, categories icons, category logo, categories logos, admin, wp-admin, category image plugin, categories images plugin, category featured image, categories featured images, feature image for category
5
  Requires at least: 2.8
6
  Tested up to: 4.3.1
7
+ Stable tag: 2.5.2
8
 
9
  The Categories Images Plugin allow you to add image with category or taxonomy.
10
 
57
 
58
  == Changelog ==
59
 
60
+ = 2.5.2 =
61
+ * Fix displaying full size image bug in backend
62
+ * Fix quick edit bug
63
+ * Some code enhancements
64
+
65
  = 2.5.1 =
66
  * Adding language support for Russian.
67
  * Adding language support for Serbian. Thanks to Andrijana Nikolic [http://webhostinggeeks.com/].