Simple Image Sizes - Version 2.0.2

Version Description

Download this release

Release Info

Developer Rahe
Plugin Icon wp plugin Simple Image Sizes
Version 2.0.2
Comparing to
See all releases

Code changes from version 2.0.1 to 2.0.2

Files changed (5) hide show
  1. inc/class.admin.php +1 -1
  2. js/sis.js +7 -0
  3. js/sis.min.js +2 -1
  4. readme.txt +4 -1
  5. simple_image_sizes.php +4 -4
inc/class.admin.php CHANGED
@@ -401,7 +401,7 @@ Class SISAdmin {
401
  $crop = isset( $_POST['crop'] ) && $_POST['crop'] == 'false' ? false : true;
402
 
403
  $values = array( 'custom' => 1, 'w' => $width , 'h' => $height, 'c' => $crop );
404
- var_dump( $values );
405
  // If the size have not changed return 2
406
  if( isset( $sizes[$name] ) && $sizes[$name] === $values ) {
407
  echo 2;
401
  $crop = isset( $_POST['crop'] ) && $_POST['crop'] == 'false' ? false : true;
402
 
403
  $values = array( 'custom' => 1, 'w' => $width , 'h' => $height, 'c' => $crop );
404
+
405
  // If the size have not changed return 2
406
  if( isset( $sizes[$name] ) && $sizes[$name] === $values ) {
407
  echo 2;
js/sis.js CHANGED
@@ -280,6 +280,13 @@ var sizes = {
280
  var parent = jQuery( el ).closest('tr');
281
  var n = parent.find('input[name=image_name]').val();
282
  var c = parent.find( 'input.c' ).attr( 'checked' );
 
 
 
 
 
 
 
283
  var w = parseInt( parent.find( 'input.w' ).val() );
284
  var h = parseInt( parent.find( 'input.h' ).val() );
285
 
280
  var parent = jQuery( el ).closest('tr');
281
  var n = parent.find('input[name=image_name]').val();
282
  var c = parent.find( 'input.c' ).attr( 'checked' );
283
+
284
+ if( c == false || c == undefined ) {
285
+ c = false;
286
+ } else {
287
+ c = true;
288
+ }
289
+
290
  var w = parseInt( parent.find( 'input.w' ).val() );
291
  var h = parseInt( parent.find( 'input.h' ).val() );
292
 
js/sis.min.js CHANGED
@@ -2,7 +2,8 @@ var regenerate={post_types:'',thumbnails:'',list:'',cur:0,percent:'',getThumbnai
2
  if(this.curr>=this.list.length){this.reInit();this.setMessage(sis.done+this.curr+' '+sis.messageRegenerated);return;}
3
  this.setMessage(sis.regenerating+(this.curr+1)+sis.of+this.list.length+" ("+this.list[this.curr].title+")...");jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:"action=ajax_thumbnail_rebuild&do=regen&id="+this.list[this.curr].id+this.thumbnails,beforeSend:function(){self.percent=(self.curr/self.list.length)*100;jQuery(".progress").progressbar("value",self.percent);jQuery(".progress-percent span.text").html(Math.round(self.percent)+"%").closest('.progress-percent').animate({left:Math.round(self.percent)-2.5+"%"},500);},success:function(r){r=eval(r);jQuery("#thumb").show();jQuery("#thumb-img").attr("src",r[0].src);self.curr++;self.regenItem();}});},reInit:function(){jQuery("#ajax_thumbnail_rebuild").removeAttr("disabled");jQuery(".progress, #thumb").hide();}}
4
  var sizes={i:0,add:function(e,el){e.preventDefault();var elTr=jQuery('<tr />').attr('valign','top').addClass('new_size_'+this.i);jQuery('<th />').attr('scope','row').append(jQuery('<input />').attr({type:'text',id:'new_size_'+this.i,}).val('thumbnail-name')).appendTo(elTr);jQuery('<td />').append(jQuery('<input />').attr({type:'button',id:'validate_'+this.i,}).val(sis.validate).addClass('button-secondary action add_size_name')).appendTo(elTr);jQuery(el).closest('tr').before(elTr);this.i++;},register:function(e,el){e.preventDefault();var name=jQuery(el).closest('tr').children('th').find('input').val();var id=jQuery(el).closest('tr').children('th').find('input').attr('id');var checkPresent=jQuery(el).closest('tbody').find('input[value="'+name+'"]').length;if(name=='thumbnail'||name=="medium"||name=="large"){alert(sis.notOriginal);return false;}else if(checkPresent!=0){alert(sis.alreadyPresent);return false;}
5
- var thEl=jQuery('<th />').attr('scope','row').text(sis.size+' '+name);var tdEl=jQuery('<td />');jQuery('<input />').attr({type:'hidden',name:'image_name'}).val(name).appendTo(tdEl);jQuery('<input />').attr({type:'hidden',name:'custom_image_sizes['+name+'][custom]'}).val("1").appendTo(tdEl);jQuery('<label />').attr('for','custom_image_sizes['+name+'][w]').text(sis.maximumWidth).append(jQuery('<input />').attr({type:'number',name:'custom_image_sizes['+name+'][w]',step:1,min:0,id:'custom_image_sizes['+name+'][w]'}).val("0").addClass("w")).appendTo(tdEl);jQuery('<label />').attr('for','custom_image_sizes['+name+'][h]').text(sis.maximumHeight).append(jQuery('<input />').attr({type:'number',name:'custom_image_sizes['+name+'][h]',step:1,min:0,id:'custom_image_sizes['+name+'][h]'}).val("0").addClass("h")).appendTo(tdEl);jQuery('<div />').addClass('crop').append(jQuery('<input />').attr({type:'checkbox',name:'custom_image_sizes['+name+'][c]',id:'custom_image_sizes['+name+'][c]'}).val("1").addClass('c')).append(jQuery('<label />').attr({'for':'checkbox',id:'custom_image_sizes['+name+'][c]'}).text(sis.crop)).appendTo(tdEl);jQuery('<div />').text(sis.deleteImage).addClass('delete_size').appendTo(tdEl);jQuery('<div />').text(sis.validateButton).addClass('add_size validate_size').appendTo(tdEl);jQuery('#'+id).closest('tr').html(thEl.after(tdEl));this.setButtons();},deleteSize:function(e,el){e.preventDefault();var confirmation=confirm(sis.confirmDelete);if(confirmation==true){jQuery(el).closest('tr').remove();this.ajaxUnregister(el);}},getPhp:function(e,el){e.preventDefault();var parent=jQuery(el).closest('tr');jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:{action:"get_sizes"},beforeSend:function(){parent.removeClass('addPending');parent.addClass('addPending');},success:function(result){jQuery('#get_php').nextAll('code').html('<br />'+result).show().css({'display':'block'});parent.removeClass('addPending');}});},ajaxRegister:function(e,el){e.preventDefault();var self=this;var timer;var parent=jQuery(el).closest('tr');var n=parent.find('input[name=image_name]').val();var c=parent.find('input.c').attr('checked');var w=parseInt(parent.find('input.w').val());var h=parseInt(parent.find('input.h').val());jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:{action:"add_size",width:w,height:h,crop:c,name:n},beforeSend:function(){parent.removeClass('errorAdding notChangedAdding successAdding');parent.addClass('addPending');},success:function(result){var classTr='';parent.removeClass('addPending');if(result==0){classTr='errorAdding';}else if(result==2){classTr='notChangedAdding';self.addToArray(n,w,h,c,classTr);}else{classTr='successAdding';self.addToArray(n,w,h,c,classTr);}
 
6
  parent.addClass(classTr);parent.find('.add_size .ui-button-text').text(sis.update);clearTimeout(timer);timer=setTimeout(function(){parent.removeClass('errorAdding notChangedAdding successAdding');},3*1000);}});},ajaxUnregister:function(el){var self=this;var n=jQuery(el).closest('tr').find('input[name=image_name]').val();jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:{action:"remove_size",name:n},success:function(result){self.removeFromArray(el);}});},addToArray:function(n,w,h,c,s){var testRow=jQuery('#sis-regen .wrapper > table > tbody input[value="'+n+'"]');var newRow='';var timer;if(testRow.length!=0)
7
  newRow=testRow.closest('tr');else
8
  newRow=jQuery('#sis-regen .wrapper > table > tbody > tr:first').clone();newRow.find('td > label').attr('for',n).end().find('input.thumbnails').val(n).attr('id',n).end().find('td:nth-child(2) > label').text(n).end().find('td:nth-child(3) > label').text(w+'px').end().find('td:nth-child(4) > label').text(h+'px').end().find('td:nth-child(5) > label').text(c);if(testRow.length==0)
2
  if(this.curr>=this.list.length){this.reInit();this.setMessage(sis.done+this.curr+' '+sis.messageRegenerated);return;}
3
  this.setMessage(sis.regenerating+(this.curr+1)+sis.of+this.list.length+" ("+this.list[this.curr].title+")...");jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:"action=ajax_thumbnail_rebuild&do=regen&id="+this.list[this.curr].id+this.thumbnails,beforeSend:function(){self.percent=(self.curr/self.list.length)*100;jQuery(".progress").progressbar("value",self.percent);jQuery(".progress-percent span.text").html(Math.round(self.percent)+"%").closest('.progress-percent').animate({left:Math.round(self.percent)-2.5+"%"},500);},success:function(r){r=eval(r);jQuery("#thumb").show();jQuery("#thumb-img").attr("src",r[0].src);self.curr++;self.regenItem();}});},reInit:function(){jQuery("#ajax_thumbnail_rebuild").removeAttr("disabled");jQuery(".progress, #thumb").hide();}}
4
  var sizes={i:0,add:function(e,el){e.preventDefault();var elTr=jQuery('<tr />').attr('valign','top').addClass('new_size_'+this.i);jQuery('<th />').attr('scope','row').append(jQuery('<input />').attr({type:'text',id:'new_size_'+this.i,}).val('thumbnail-name')).appendTo(elTr);jQuery('<td />').append(jQuery('<input />').attr({type:'button',id:'validate_'+this.i,}).val(sis.validate).addClass('button-secondary action add_size_name')).appendTo(elTr);jQuery(el).closest('tr').before(elTr);this.i++;},register:function(e,el){e.preventDefault();var name=jQuery(el).closest('tr').children('th').find('input').val();var id=jQuery(el).closest('tr').children('th').find('input').attr('id');var checkPresent=jQuery(el).closest('tbody').find('input[value="'+name+'"]').length;if(name=='thumbnail'||name=="medium"||name=="large"){alert(sis.notOriginal);return false;}else if(checkPresent!=0){alert(sis.alreadyPresent);return false;}
5
+ var thEl=jQuery('<th />').attr('scope','row').text(sis.size+' '+name);var tdEl=jQuery('<td />');jQuery('<input />').attr({type:'hidden',name:'image_name'}).val(name).appendTo(tdEl);jQuery('<input />').attr({type:'hidden',name:'custom_image_sizes['+name+'][custom]'}).val("1").appendTo(tdEl);jQuery('<label />').attr('for','custom_image_sizes['+name+'][w]').text(sis.maximumWidth).append(jQuery('<input />').attr({type:'number',name:'custom_image_sizes['+name+'][w]',step:1,min:0,id:'custom_image_sizes['+name+'][w]'}).val("0").addClass("w")).appendTo(tdEl);jQuery('<label />').attr('for','custom_image_sizes['+name+'][h]').text(sis.maximumHeight).append(jQuery('<input />').attr({type:'number',name:'custom_image_sizes['+name+'][h]',step:1,min:0,id:'custom_image_sizes['+name+'][h]'}).val("0").addClass("h")).appendTo(tdEl);jQuery('<div />').addClass('crop').append(jQuery('<input />').attr({type:'checkbox',name:'custom_image_sizes['+name+'][c]',id:'custom_image_sizes['+name+'][c]'}).val("1").addClass('c')).append(jQuery('<label />').attr({'for':'checkbox',id:'custom_image_sizes['+name+'][c]'}).text(sis.crop)).appendTo(tdEl);jQuery('<div />').text(sis.deleteImage).addClass('delete_size').appendTo(tdEl);jQuery('<div />').text(sis.validateButton).addClass('add_size validate_size').appendTo(tdEl);jQuery('#'+id).closest('tr').html(thEl.after(tdEl));this.setButtons();},deleteSize:function(e,el){e.preventDefault();var confirmation=confirm(sis.confirmDelete);if(confirmation==true){jQuery(el).closest('tr').remove();this.ajaxUnregister(el);}},getPhp:function(e,el){e.preventDefault();var parent=jQuery(el).closest('tr');jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:{action:"get_sizes"},beforeSend:function(){parent.removeClass('addPending');parent.addClass('addPending');},success:function(result){jQuery('#get_php').nextAll('code').html('<br />'+result).show().css({'display':'block'});parent.removeClass('addPending');}});},ajaxRegister:function(e,el){e.preventDefault();var self=this;var timer;var parent=jQuery(el).closest('tr');var n=parent.find('input[name=image_name]').val();var c=parent.find('input.c').attr('checked');if(c==false||c==undefined){c=false;}else{c=true;}
6
+ var w=parseInt(parent.find('input.w').val());var h=parseInt(parent.find('input.h').val());jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:{action:"add_size",width:w,height:h,crop:c,name:n},beforeSend:function(){parent.removeClass('errorAdding notChangedAdding successAdding');parent.addClass('addPending');},success:function(result){var classTr='';parent.removeClass('addPending');if(result==0){classTr='errorAdding';}else if(result==2){classTr='notChangedAdding';self.addToArray(n,w,h,c,classTr);}else{classTr='successAdding';self.addToArray(n,w,h,c,classTr);}
7
  parent.addClass(classTr);parent.find('.add_size .ui-button-text').text(sis.update);clearTimeout(timer);timer=setTimeout(function(){parent.removeClass('errorAdding notChangedAdding successAdding');},3*1000);}});},ajaxUnregister:function(el){var self=this;var n=jQuery(el).closest('tr').find('input[name=image_name]').val();jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:{action:"remove_size",name:n},success:function(result){self.removeFromArray(el);}});},addToArray:function(n,w,h,c,s){var testRow=jQuery('#sis-regen .wrapper > table > tbody input[value="'+n+'"]');var newRow='';var timer;if(testRow.length!=0)
8
  newRow=testRow.closest('tr');else
9
  newRow=jQuery('#sis-regen .wrapper > table > tbody > tr:first').clone();newRow.find('td > label').attr('for',n).end().find('input.thumbnails').val(n).attr('id',n).end().find('td:nth-child(2) > label').text(n).end().find('td:nth-child(3) > label').text(w+'px').end().find('td:nth-child(4) > label').text(h+'px').end().find('td:nth-child(5) > label').text(c);if(testRow.length==0)
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.beapi.fr/donate/
4
  Tags: images, image, custom sizes, custom images, thumbnail regenerate, thumbnail, regenerate
5
  Requires at least: 3.0
6
  Tested up to: 3.2
7
- Stable tag: 2.0.1
8
 
9
  == Description ==
10
 
@@ -28,6 +28,9 @@ Now you can use the generated sizes directly into your posts and insert images a
28
  3. In posts thumbnails
29
 
30
  == Changelog ==
 
 
 
31
  * 2.0.1
32
  * Resolve javascript issue when clicking on delete button
33
  * Resolve issue of never unchecking crop button
4
  Tags: images, image, custom sizes, custom images, thumbnail regenerate, thumbnail, regenerate
5
  Requires at least: 3.0
6
  Tested up to: 3.2
7
+ Stable tag: 2.0.2
8
 
9
  == Description ==
10
 
28
  3. In posts thumbnails
29
 
30
  == Changelog ==
31
+ * 2.0.2
32
+ * Remove debug on php for javascript
33
+ * Resolve issue with the different versions on jquery ( like in WP3.2 ) with attr return for checked components
34
  * 2.0.1
35
  * Resolve javascript issue when clicking on delete button
36
  * Resolve issue of never unchecking crop button
simple_image_sizes.php CHANGED
@@ -3,12 +3,12 @@
3
  Plugin Name: Simple Image Size
4
  Plugin URI: http://redmine.beapi.fr/projects/show/simple-image-sizes
5
  Description: Add options in media setting page for images sizes
6
- Version: 2.0.1
7
  Author: Rahe
8
- Author URI: http://www.beapi.fr
9
  Text Domain: sis
10
  Domain Path: /languages/
11
- Network: false
12
 
13
  Copyright 2011 Nicolas JUEN (njuen@beapi.fr) - Be-API
14
 
@@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
 
30
  define( 'SIS_URL', plugins_url('/', __FILE__) );
31
  define( 'SIS_DIR', dirname(__FILE__) );
32
- define( 'SIS_VERSION', '2.0' );
33
  define( 'SIS_OPTION', 'custom_image_sizes' );
34
 
35
  require_once( SIS_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'class.admin.php' );
3
  Plugin Name: Simple Image Size
4
  Plugin URI: http://redmine.beapi.fr/projects/show/simple-image-sizes
5
  Description: Add options in media setting page for images sizes
6
+ Version: 2.0.2
7
  Author: Rahe
8
+ Author URI: http://nicolas-juen.fr
9
  Text Domain: sis
10
  Domain Path: /languages/
11
+ Network: true
12
 
13
  Copyright 2011 Nicolas JUEN (njuen@beapi.fr) - Be-API
14
 
29
 
30
  define( 'SIS_URL', plugins_url('/', __FILE__) );
31
  define( 'SIS_DIR', dirname(__FILE__) );
32
+ define( 'SIS_VERSION', '2.0.2' );
33
  define( 'SIS_OPTION', 'custom_image_sizes' );
34
 
35
  require_once( SIS_DIR . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'class.admin.php' );