Simple Image Sizes - Version 3.0.1

Version Description

Download this release

Release Info

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

Code changes from version 3.0 to 3.0.1

README CHANGED
@@ -9,7 +9,7 @@
9
 
10
  **Tested up to:** 3.9
11
 
12
- **Stable tag:** 3.0
13
 
14
 
15
  ## Description ##
@@ -64,6 +64,11 @@ And then you can choose if the image is displayed on the media insertion or not
64
  ](http://s.wordpress.org/extend/plugins/simple-image-sizes/screenshot-3.png)
65
 
66
  ## Changelog ##
 
 
 
 
 
67
  * 3.0
68
  * Revamping all the code, change classes and structure
69
  * Use grunt for compiling files
9
 
10
  **Tested up to:** 3.9
11
 
12
+ **Stable tag:** 3.0.1
13
 
14
 
15
  ## Description ##
64
  ](http://s.wordpress.org/extend/plugins/simple-image-sizes/screenshot-3.png)
65
 
66
  ## Changelog ##
67
+ * 3.0.1
68
+ * Change the template render method for non apache webservers : https://wordpress.org/support/topic/fatal-error-1190?replies=6
69
+ * Remove ambigious ids for the css bugging WooCommerce : https://wordpress.org/support/topic/bad-css-style-administration and
70
+ * Right code for counting the elements on backoffice : https://github.com/Rahe/Simple-image-sizes/issues/20
71
+ * Fix bug on regenation and _e instead of __ : https://plugins.trac.wordpress.org/ticket/2259
72
  * 3.0
73
  * Revamping all the code, change classes and structure
74
  * Use grunt for compiling files
assets/css/sis-style.css CHANGED
@@ -38,8 +38,9 @@ tr.errorAdding {
38
  tr.notChangedAdding {
39
  background-color: #F2A13A;
40
  }
41
-
42
- #regenerate_message, #time, #thumb {
 
43
  display: none;
44
  }
45
 
@@ -52,7 +53,7 @@ tr.notChangedAdding {
52
  font-weight: bold;
53
  }
54
 
55
- #time .ui-state-highlight{
56
  margin-top: 20px;
57
  padding: 0 .7em;
58
  }
38
  tr.notChangedAdding {
39
  background-color: #F2A13A;
40
  }
41
+ .sis .regenerate_message,
42
+ .sis .time,
43
+ .sis .thumb {
44
  display: none;
45
  }
46
 
53
  font-weight: bold;
54
  }
55
 
56
+ .sis .time .ui-state-highlight{
57
  margin-top: 20px;
58
  padding: 0 .7em;
59
  }
assets/css/sis-style.min.css CHANGED
@@ -1 +1 @@
1
- .media-item.sis{display:none}.media-item.sis .progress{width:100%}input.h,input.w{border-color:#DFDFDF;background-color:#fff;border-width:1px;border-style:solid;-moz-border-radius:3px;-khtml-border-radius:3px;-webkit-border-radius:3px;border-radius:3px}tr{-webkit-transition:all .5s ease-in-out;-moz-transition:all .5s ease-in-out;-o-transition:all .5s ease-in-out;transition:all .5s ease-in-out}table.sis tr:nth-child(even){background-color:#FCFCFC}table.sis tr:nth-child(odd){background-color:transparent}tr.addPending{background-color:#6CA1D7}tr.successAdding{background-color:#89D76A}tr.errorAdding{background-color:#C45858}tr.notChangedAdding{background-color:#F2A13A}#regenerate_message,#thumb,#time{display:none}#ajax_thumbnail_rebuild{margin-top:40px}#sis_progress-percent{width:100%;text-align:center;font-weight:700}#time .ui-state-highlight{margin-top:20px;padding:0 .7em}#post-body .sis-regenerate-one{float:left}
1
+ .media-item.sis{display:none}.media-item.sis .progress{width:100%}input.h,input.w{border-color:#DFDFDF;background-color:#fff;border-width:1px;border-style:solid;-moz-border-radius:3px;-khtml-border-radius:3px;-webkit-border-radius:3px;border-radius:3px}tr{-webkit-transition:all .5s ease-in-out;-moz-transition:all .5s ease-in-out;-o-transition:all .5s ease-in-out;transition:all .5s ease-in-out}table.sis tr:nth-child(even){background-color:#FCFCFC}table.sis tr:nth-child(odd){background-color:transparent}tr.addPending{background-color:#6CA1D7}tr.successAdding{background-color:#89D76A}tr.errorAdding{background-color:#C45858}tr.notChangedAdding{background-color:#F2A13A}.sis .regenerate_message,.sis .thumb,.sis .time{display:none}#ajax_thumbnail_rebuild{margin-top:40px}#sis_progress-percent{width:100%;text-align:center;font-weight:700}.sis .time .ui-state-highlight{margin-top:20px;padding:0 .7em}#post-body .sis-regenerate-one{float:left}
assets/js/sis.js CHANGED
@@ -23,6 +23,7 @@ rahe.sis.regenerate = {
23
  percentText : null,
24
  progress : null,
25
  messageZone : null,
 
26
  time : null,
27
  timeZone : null,
28
  buttonRegenerate : null,
@@ -31,16 +32,17 @@ rahe.sis.regenerate = {
31
  thumb : null,
32
  thumbImg : null,
33
  init : function() {
 
34
  this.percentText = jQuery('#sis_progress-percent');
35
  this.progress = jQuery( '.progress' );
36
- this.messageZone = jQuery("#regenerate_message");
37
- this.time = jQuery("#time");
38
  this.timeZone = this.time.find("p span.time_message");
39
  this.buttonRegenerate = jQuery( "#ajax_thumbnail_rebuild" );
40
  this.errorZone = jQuery( '#error_messages' );
41
  this.errorMessages = this.errorZone.find( 'ul.messages' );
42
- this.thumb = jQuery( '#thumb' );
43
- this.thumbImg = jQuery( '#thumb-img' );
44
  },
45
  getThumbnails : function() {
46
  var self = this,
@@ -157,6 +159,7 @@ rahe.sis.regenerate = {
157
 
158
  // Set the message of current image regenerating
159
  this.setMessage( sis.regenerating + ( this.curr + 1 ) + sis.of + this.total );
 
160
 
161
  jQuery.ajax( {
162
  url: sis.ajaxUrl,
@@ -266,7 +269,7 @@ rahe.sis.regenerate = {
266
  this.progress.hide();
267
  this.percentText.addClass( 'hidden' );
268
  }
269
- }
270
 
271
  rahe.sis.sizes = {
272
  i: 0,
@@ -274,7 +277,8 @@ rahe.sis.sizes = {
274
  e.preventDefault();
275
 
276
  // Create the template
277
- var elTr = _.template( document.getElementById( 'sis-new_size' ).text, {
 
278
  size_id : this.i,
279
  validate : sis.validate
280
  } );
@@ -304,8 +308,10 @@ rahe.sis.sizes = {
304
  alert( sis.alreadyPresent );
305
  return false;
306
  }
307
-
308
- var row = _.template( document.getElementById( 'sis-new_size_row' ).text, {
 
 
309
  size : sis.size,
310
  size_name : name,
311
  maximumWidth : sis.maximumWidth,
@@ -317,7 +323,7 @@ rahe.sis.sizes = {
317
  deleteImage : sis.deleteImage,
318
  validateButton : sis.validateButton
319
  } );
320
-
321
  // Add the row to the current list
322
  jQuery('#' + id).closest( 'tr' ).html( row );
323
  },
@@ -531,6 +537,22 @@ rahe.sis.sizes = {
531
  }
532
  }
533
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  jQuery(function() {
535
  rahe.sis.regenerate.init();
536
  var bodyContent = jQuery( '#wpbody-content');
23
  percentText : null,
24
  progress : null,
25
  messageZone : null,
26
+ sisZone : null,
27
  time : null,
28
  timeZone : null,
29
  buttonRegenerate : null,
32
  thumb : null,
33
  thumbImg : null,
34
  init : function() {
35
+ this.sisZone = jQuery('.sis');
36
  this.percentText = jQuery('#sis_progress-percent');
37
  this.progress = jQuery( '.progress' );
38
+ this.messageZone = this.sisZone.find(".regenerate_message");
39
+ this.time = this.sisZone.find(".time");
40
  this.timeZone = this.time.find("p span.time_message");
41
  this.buttonRegenerate = jQuery( "#ajax_thumbnail_rebuild" );
42
  this.errorZone = jQuery( '#error_messages' );
43
  this.errorMessages = this.errorZone.find( 'ul.messages' );
44
+ this.thumb = this.sisZone.find( '.thumb' );
45
+ this.thumbImg = this.sisZone.find( '.thumb-img' );
46
  },
47
  getThumbnails : function() {
48
  var self = this,
159
 
160
  // Set the message of current image regenerating
161
  this.setMessage( sis.regenerating + ( this.curr + 1 ) + sis.of + this.total );
162
+ this.setMessage( sis.regenerating + ( this.curr + 1 ) + sis.of + this.total );
163
 
164
  jQuery.ajax( {
165
  url: sis.ajaxUrl,
269
  this.progress.hide();
270
  this.percentText.addClass( 'hidden' );
271
  }
272
+ };
273
 
274
  rahe.sis.sizes = {
275
  i: 0,
277
  e.preventDefault();
278
 
279
  // Create the template
280
+ var elTr = rahe.sis.template( 'new_size' );
281
+ elTr = elTr( {
282
  size_id : this.i,
283
  validate : sis.validate
284
  } );
308
  alert( sis.alreadyPresent );
309
  return false;
310
  }
311
+
312
+ var row = rahe.sis.template( 'new_size_row' );
313
+
314
+ row = row( {
315
  size : sis.size,
316
  size_name : name,
317
  maximumWidth : sis.maximumWidth,
323
  deleteImage : sis.deleteImage,
324
  validateButton : sis.validateButton
325
  } );
326
+
327
  // Add the row to the current list
328
  jQuery('#' + id).closest( 'tr' ).html( row );
329
  },
537
  }
538
  }
539
  }
540
+
541
+ rahe.sis.template = _.memoize( function ( id ) {
542
+ var compiled,
543
+ options = {
544
+ evaluate: /<#([\s\S]+?)#>/g,
545
+ interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
546
+ escape: /\{\{([^\}]+?)\}\}(?!\})/g,
547
+ variable: 'data'
548
+ };
549
+
550
+ return function ( data ) {
551
+ compiled = compiled || _.template( jQuery( '#sis-' + id ).html(), null, options );
552
+ return compiled( data );
553
+ };
554
+ });
555
+
556
  jQuery(function() {
557
  rahe.sis.regenerate.init();
558
  var bodyContent = jQuery( '#wpbody-content');
assets/js/sis.min.js CHANGED
@@ -1 +1 @@
1
- var rahe;if(rahe){if("object"!=typeof rahe)throw new Error("rahe already exists and not an object")}else rahe={};if(rahe.sis){if("object"!=typeof rahe.sis)throw new Error("rahe.sis already exists and not an object")}else rahe.sis={};rahe.sis.regenerate={post_types:[],thumbnails:[],total:0,cur:0,timeScript:[],dateScript:"",percent:"",percentText:null,progress:null,messageZone:null,time:null,timeZone:null,buttonRegenerate:null,errorZone:null,errorMessages:null,thumb:null,thumbImg:null,init:function(){this.percentText=jQuery("#sis_progress-percent"),this.progress=jQuery(".progress"),this.messageZone=jQuery("#regenerate_message"),this.time=jQuery("#time"),this.timeZone=this.time.find("p span.time_message"),this.buttonRegenerate=jQuery("#ajax_thumbnail_rebuild"),this.errorZone=jQuery("#error_messages"),this.errorMessages=this.errorZone.find("ul.messages"),this.thumb=jQuery("#thumb"),this.thumbImg=jQuery("#thumb-img")},getThumbnails:function(){var a=this,b=jQuery("input.thumbnails:checked");b.length!=jQuery('input.thumbnails[type="checkbox"]').length&&b.each(function(){a.thumbnails.push(this.value)})},getPostTypes:function(){var a=this,b=jQuery("input.post_types:checked");b.length!=jQuery('input.post_types[type="checkbox"]').length&&b.each(function(){a.post_types.push(this.value)})},setMessage:function(a){this.messageZone.html("<p>"+a+"</p>").addClass("updated").addClass("fade").show()},setTimeMessage:function(a){this.timeZone.html(a)},checkStartRegenerating:function(){if(jQuery(".notSaved").size()>0){var a=confirm(sis.notSaved);if(1!=a)return!1;this.startRegenerating()}else this.startRegenerating()},startRegenerating:function(){var a=this,b=jQuery("input.getList").val();a.getThumbnails(),a.getPostTypes(),this.dateScript=new Date,jQuery.ajax({url:sis.ajaxUrl,type:"POST",dataType:"json",data:{action:"sis_get_list",post_types:a.post_types,nonce:b},beforeSend:function(){a.buttonRegenerate.attr("disabled",!0),a.setMessage(sis.reading)},success:function(b){return"object"!=typeof b?(a.reInit(),a.setMessage(sis.phpError),!1):(a.time.show(),a.total=b.total,a.curr=0,a.progress.show().parent().show(),void a.regenItem())}})},regenItem:function(){var a=this,b=jQuery("input.regen").val();if(0==this.total||_.isUndefined(this.total))return this.reInit(),this.setMessage(sis.noMedia),!1;if(this.curr>=this.total){var c=new Date;return this.reInit(),void this.setMessage(sis.done+this.curr+" "+sis.messageRegenerated+sis.startedAt+" "+this.dateScript.getHours()+":"+this.dateScript.getMinutes()+":"+this.dateScript.getSeconds()+sis.finishedAt+" "+c.getHours()+":"+c.getMinutes()+":"+c.getSeconds())}this.setMessage(sis.regenerating+(this.curr+1)+sis.of+this.total),jQuery.ajax({url:sis.ajaxUrl,type:"POST",dataType:"json",data:{action:"sis_rebuild_images",offset:this.curr,thumbnails:this.thumbnails,nonce:b},beforeSend:function(){a.percent=a.curr/a.total*100,a.progress.find(".bar").width(a.percent+"%").find(".percent").html(a.percent+"%"),a.percentText.removeClass("hidden").html(Math.round(a.percent)+"%")},success:function(b){if(b.src&&b.time&&!b.error&&"object"==typeof b){b.message&&a.time.find("ul.messages").prepend("<li>"+b.message+"</li>"),a.thumb.show(),a.thumbImg.attr("src",b.src);var c=new Date,d=new Date,e=0,f=0,g=0,h=0,i="";for(a.timeScript.push(parseFloat(b.time.replace(",","."),10)),e=a.timeScript.length,g;e>g;g++)f+=a.timeScript[g];h=f/e,t=Math.round(h*a.total*1e3),c.setTime(a.dateScript.getTime()+t),i=a.s2t(Math.abs(c.getTime()-d.getTime())/1e3),a.setTimeMessage(c.getHours()+":"+c.getMinutes()+":"+c.getSeconds()+sis.or+i+sis.beforeEnd)}else{var j="";j="object"!=typeof b?sis.phpError:b.error,a.errorZone.addClass("error message"),a.errorMessages.prepend("<li>"+j+"</li>")}a.curr++,a.regenItem()}})},s2t:function(a){var a=a%86400,b=new Date(1970,0,1),c=0;return b.setSeconds(a),c=b.toTimeString().substr(0,8),a>86399&&(c=Math.floor((b-Date.parse("1/1/70"))/36e5)+c.substr(2)),c},reInit:function(){this.buttonRegenerate.removeAttr("disabled"),this.thumb.hide(),this.progress.hide(),this.percentText.addClass("hidden")}},rahe.sis.sizes={i:0,add:function(a,b){a.preventDefault();var c=_.template(document.getElementById("sis-new_size").text,{size_id:this.i,validate:sis.validate});jQuery(b).closest("tr").before(c),this.i++},register:function(a,b){a.preventDefault();var c=jQuery(b).closest("tr").children("th").find("input").val(),d=jQuery(b).closest("tr").children("th").find("input").attr("id"),e=jQuery(b).closest("tbody").find('input[value="'+c+'"]').length;if("thumbnail"==c||"medium"==c||"large"==c)return alert(sis.notOriginal),!1;if(0!=e)return alert(sis.alreadyPresent),!1;var f=_.template(document.getElementById("sis-new_size_row").text,{size:sis.size,size_name:c,maximumWidth:sis.maximumWidth,maximumHeight:sis.maximumHeight,customName:sis.customName,crop:sis.crop,crop_positions:sis.crop_positions,show:sis.show,deleteImage:sis.deleteImage,validateButton:sis.validateButton});jQuery("#"+d).closest("tr").html(f)},deleteSize:function(a,b){a.preventDefault();var c=confirm(sis.confirmDelete);1==c&&(jQuery(b).closest("tr").remove(),this.ajaxUnregister(b))},getPhp:function(a,b){a.preventDefault();var c=jQuery(b).closest("tr");jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:{action:"sis_get_sizes"},beforeSend:function(){c.removeClass("addPending"),c.addClass("addPending")},success:function(a){jQuery("#get_php").nextAll("code").html("<br />"+a).show().css({display:"block"}),c.removeClass("addPending")}})},ajaxRegister:function(a,b){a.preventDefault();var c,d=this,e=jQuery(b).closest("table"),f=jQuery(".addSize").val(),g=jQuery(b).closest("tr"),h=g.find('input[name="image_name"]').val(),i=g.find("select.crop").val(),j=g.find("input.show").val(),k=g.find("input.n").val(),l=0,m=0;j=0==j||void 0==j?!1:!0,m=parseInt(g.find("input.w").val()),l=parseInt(g.find("input.h").val()),e.hasClass("ajaxing")||jQuery.ajax({url:sis.ajaxUrl,type:"POST",dataType:"json",data:{action:"sis_add_size",width:m,height:l,crop:i,name:h,show:j,customName:k,nonce:f},beforeSend:function(){g.removeClass(),g.addClass("addPending"),e.addClass("ajaxing")},success:function(a){var b="";g.removeClass(),e.removeClass("ajaxing"),0==a?b="errorAdding":2==a?(b="notChangedAdding",d.addToArray(h,m,l,i,b)):(b="successAdding",d.addToArray(h,m,l,i,b)),g.find("input.h").attr({base_h:l}),g.find("input.w").attr({base_w:m}),g.find("select.c").attr({base_c:i}),g.find("input.s").attr({base_s:j}),g.addClass(b),g.find("td").removeClass("notSaved"),g.find(".add_size").removeClass("validate_size").hide().children(".ui-button-text").text(sis.update),clearTimeout(c),c=setTimeout(function(){g.removeClass("errorAdding notChangedAdding successAdding")},2e3)}})},ajaxUnregister:function(a){var b=this,c=jQuery(a).closest("tr").find('input[name="image_name"]').val(),d=jQuery(a).closest("tr").find("input.deleteSize").val();jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:{action:"sis_remove_size",name:c,nonce:d},success:function(){b.removeFromArray(a)}})},addToArray:function(a,b,c,d,e){var f,g=jQuery("#sis-"+a),h="";h=0!=g.length?g.closest("tr"):jQuery("#sis-regen .wrapper > table#sis_sizes > tbody > tr:first").clone().attr("id","sis-"+a),d=_.isUndefined(sis.crop_positions[d])?sis.fl:sis.crop_positions[d],h.find("th > label").attr("for",a).end().find("input.thumbnails").val(a).attr("id",a).end().find("th:nth-child(2) > label").text(a).end().find("th:nth-child(3) > label").text(b+"px").end().find("th:nth-child(4) > label").text(c+"px").end().find("th:nth-child(5) > label").text(d),0==g.length&&h.appendTo("#sis-regen .wrapper > table#sis_sizes > tbody"),h.removeClass("errorAdding notChangedAdding successAdding").addClass(e),clearTimeout(f),f=setTimeout(function(){h.removeClass("errorAdding notChangedAdding successAdding")},3e3)},removeFromArray:function(a){var b=jQuery(a).closest("tr").find("input[name=image_name]").val();jQuery("#sis-"+b).remove()},displayChange:function(a){var a=jQuery(a),b=a.closest("tr");if(b.hasClass("new_size"))return!1;var c=b.find("input.h"),d=b.find("input.w"),e=b.find("select.c"),f=b.find("input.s"),g=b.find("input.n"),h=c.val(),i=d.val(),j=e.val(),k=f.val(),l=g.val(),m=c.attr("base_h"),n=d.attr("base_w"),o=e.attr("base_c"),p=f.attr("base_s"),q=g.attr("base_n");o="0"==o?!1:!0,p="0"==p?!1:!0,h!=m||i!=n||j!=o||k!=p||l!=q?a.closest("td").addClass("notSaved").find(".add_size").css("display","inline-block"):a.closest("td").removeClass("notSaved").find(".add_size").css("display","none")}},jQuery(function(){rahe.sis.regenerate.init();var a=jQuery("#wpbody-content");jQuery("#ajax_thumbnail_rebuild").click(function(){rahe.sis.regenerate.checkStartRegenerating()}),a.on("click","#add_size",function(a){rahe.sis.sizes.add(a,this)}).on("click",".add_size_name",function(a){rahe.sis.sizes.register(a,this)}).on("click",".delete_size",function(a){rahe.sis.sizes.deleteSize(a,this)}).on("click",".add_size",function(a){rahe.sis.sizes.ajaxRegister(a,this)}).on("click keyup change",".h,.w,.c,.s,.n",function(){rahe.sis.sizes.displayChange(this)}).on("click","#get_php",function(a){rahe.sis.sizes.getPhp(a,this)}),jQuery("#get_php").nextAll("code").hide(),jQuery(".add_size").hide()});
1
+ var rahe;if(rahe){if("object"!=typeof rahe)throw new Error("rahe already exists and not an object")}else rahe={};if(rahe.sis){if("object"!=typeof rahe.sis)throw new Error("rahe.sis already exists and not an object")}else rahe.sis={};rahe.sis.regenerate={post_types:[],thumbnails:[],total:0,cur:0,timeScript:[],dateScript:"",percent:"",percentText:null,progress:null,messageZone:null,sisZone:null,time:null,timeZone:null,buttonRegenerate:null,errorZone:null,errorMessages:null,thumb:null,thumbImg:null,init:function(){this.sisZone=jQuery(".sis"),this.percentText=jQuery("#sis_progress-percent"),this.progress=jQuery(".progress"),this.messageZone=this.sisZone.find(".regenerate_message"),this.time=this.sisZone.find(".time"),this.timeZone=this.time.find("p span.time_message"),this.buttonRegenerate=jQuery("#ajax_thumbnail_rebuild"),this.errorZone=jQuery("#error_messages"),this.errorMessages=this.errorZone.find("ul.messages"),this.thumb=this.sisZone.find(".thumb"),this.thumbImg=this.sisZone.find(".thumb-img")},getThumbnails:function(){var a=this,b=jQuery("input.thumbnails:checked");b.length!=jQuery('input.thumbnails[type="checkbox"]').length&&b.each(function(){a.thumbnails.push(this.value)})},getPostTypes:function(){var a=this,b=jQuery("input.post_types:checked");b.length!=jQuery('input.post_types[type="checkbox"]').length&&b.each(function(){a.post_types.push(this.value)})},setMessage:function(a){this.messageZone.html("<p>"+a+"</p>").addClass("updated").addClass("fade").show()},setTimeMessage:function(a){this.timeZone.html(a)},checkStartRegenerating:function(){if(jQuery(".notSaved").size()>0){var a=confirm(sis.notSaved);if(1!=a)return!1;this.startRegenerating()}else this.startRegenerating()},startRegenerating:function(){var a=this,b=jQuery("input.getList").val();a.getThumbnails(),a.getPostTypes(),this.dateScript=new Date,jQuery.ajax({url:sis.ajaxUrl,type:"POST",dataType:"json",data:{action:"sis_get_list",post_types:a.post_types,nonce:b},beforeSend:function(){a.buttonRegenerate.attr("disabled",!0),a.setMessage(sis.reading)},success:function(b){return"object"!=typeof b?(a.reInit(),a.setMessage(sis.phpError),!1):(a.time.show(),a.total=b.total,a.curr=0,a.progress.show().parent().show(),void a.regenItem())}})},regenItem:function(){var a=this,b=jQuery("input.regen").val();if(0==this.total||_.isUndefined(this.total))return this.reInit(),this.setMessage(sis.noMedia),!1;if(this.curr>=this.total){var c=new Date;return this.reInit(),void this.setMessage(sis.done+this.curr+" "+sis.messageRegenerated+sis.startedAt+" "+this.dateScript.getHours()+":"+this.dateScript.getMinutes()+":"+this.dateScript.getSeconds()+sis.finishedAt+" "+c.getHours()+":"+c.getMinutes()+":"+c.getSeconds())}this.setMessage(sis.regenerating+(this.curr+1)+sis.of+this.total),this.setMessage(sis.regenerating+(this.curr+1)+sis.of+this.total),jQuery.ajax({url:sis.ajaxUrl,type:"POST",dataType:"json",data:{action:"sis_rebuild_images",offset:this.curr,thumbnails:this.thumbnails,nonce:b},beforeSend:function(){a.percent=a.curr/a.total*100,a.progress.find(".bar").width(a.percent+"%").find(".percent").html(a.percent+"%"),a.percentText.removeClass("hidden").html(Math.round(a.percent)+"%")},success:function(b){if(b.src&&b.time&&!b.error&&"object"==typeof b){b.message&&a.time.find("ul.messages").prepend("<li>"+b.message+"</li>"),a.thumb.show(),a.thumbImg.attr("src",b.src);var c=new Date,d=new Date,e=0,f=0,g=0,h=0,i="";for(a.timeScript.push(parseFloat(b.time.replace(",","."),10)),e=a.timeScript.length,g;e>g;g++)f+=a.timeScript[g];h=f/e,t=Math.round(h*a.total*1e3),c.setTime(a.dateScript.getTime()+t),i=a.s2t(Math.abs(c.getTime()-d.getTime())/1e3),a.setTimeMessage(c.getHours()+":"+c.getMinutes()+":"+c.getSeconds()+sis.or+i+sis.beforeEnd)}else{var j="";j="object"!=typeof b?sis.phpError:b.error,a.errorZone.addClass("error message"),a.errorMessages.prepend("<li>"+j+"</li>")}a.curr++,a.regenItem()}})},s2t:function(a){var a=a%86400,b=new Date(1970,0,1),c=0;return b.setSeconds(a),c=b.toTimeString().substr(0,8),a>86399&&(c=Math.floor((b-Date.parse("1/1/70"))/36e5)+c.substr(2)),c},reInit:function(){this.buttonRegenerate.removeAttr("disabled"),this.thumb.hide(),this.progress.hide(),this.percentText.addClass("hidden")}},rahe.sis.sizes={i:0,add:function(a,b){a.preventDefault();var c=rahe.sis.template("new_size");c=c({size_id:this.i,validate:sis.validate}),jQuery(b).closest("tr").before(c),this.i++},register:function(a,b){a.preventDefault();var c=jQuery(b).closest("tr").children("th").find("input").val(),d=jQuery(b).closest("tr").children("th").find("input").attr("id"),e=jQuery(b).closest("tbody").find('input[value="'+c+'"]').length;if("thumbnail"==c||"medium"==c||"large"==c)return alert(sis.notOriginal),!1;if(0!=e)return alert(sis.alreadyPresent),!1;var f=rahe.sis.template("new_size_row");f=f({size:sis.size,size_name:c,maximumWidth:sis.maximumWidth,maximumHeight:sis.maximumHeight,customName:sis.customName,crop:sis.crop,crop_positions:sis.crop_positions,show:sis.show,deleteImage:sis.deleteImage,validateButton:sis.validateButton}),jQuery("#"+d).closest("tr").html(f)},deleteSize:function(a,b){a.preventDefault();var c=confirm(sis.confirmDelete);1==c&&(jQuery(b).closest("tr").remove(),this.ajaxUnregister(b))},getPhp:function(a,b){a.preventDefault();var c=jQuery(b).closest("tr");jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:{action:"sis_get_sizes"},beforeSend:function(){c.removeClass("addPending"),c.addClass("addPending")},success:function(a){jQuery("#get_php").nextAll("code").html("<br />"+a).show().css({display:"block"}),c.removeClass("addPending")}})},ajaxRegister:function(a,b){a.preventDefault();var c,d=this,e=jQuery(b).closest("table"),f=jQuery(".addSize").val(),g=jQuery(b).closest("tr"),h=g.find('input[name="image_name"]').val(),i=g.find("select.crop").val(),j=g.find("input.show").val(),k=g.find("input.n").val(),l=0,m=0;j=0==j||void 0==j?!1:!0,m=parseInt(g.find("input.w").val()),l=parseInt(g.find("input.h").val()),e.hasClass("ajaxing")||jQuery.ajax({url:sis.ajaxUrl,type:"POST",dataType:"json",data:{action:"sis_add_size",width:m,height:l,crop:i,name:h,show:j,customName:k,nonce:f},beforeSend:function(){g.removeClass(),g.addClass("addPending"),e.addClass("ajaxing")},success:function(a){var b="";g.removeClass(),e.removeClass("ajaxing"),0==a?b="errorAdding":2==a?(b="notChangedAdding",d.addToArray(h,m,l,i,b)):(b="successAdding",d.addToArray(h,m,l,i,b)),g.find("input.h").attr({base_h:l}),g.find("input.w").attr({base_w:m}),g.find("select.c").attr({base_c:i}),g.find("input.s").attr({base_s:j}),g.addClass(b),g.find("td").removeClass("notSaved"),g.find(".add_size").removeClass("validate_size").hide().children(".ui-button-text").text(sis.update),clearTimeout(c),c=setTimeout(function(){g.removeClass("errorAdding notChangedAdding successAdding")},2e3)}})},ajaxUnregister:function(a){var b=this,c=jQuery(a).closest("tr").find('input[name="image_name"]').val(),d=jQuery(a).closest("tr").find("input.deleteSize").val();jQuery.ajax({url:sis.ajaxUrl,type:"POST",data:{action:"sis_remove_size",name:c,nonce:d},success:function(){b.removeFromArray(a)}})},addToArray:function(a,b,c,d,e){var f,g=jQuery("#sis-"+a),h="";h=0!=g.length?g.closest("tr"):jQuery("#sis-regen .wrapper > table#sis_sizes > tbody > tr:first").clone().attr("id","sis-"+a),d=_.isUndefined(sis.crop_positions[d])?sis.fl:sis.crop_positions[d],h.find("th > label").attr("for",a).end().find("input.thumbnails").val(a).attr("id",a).end().find("th:nth-child(2) > label").text(a).end().find("th:nth-child(3) > label").text(b+"px").end().find("th:nth-child(4) > label").text(c+"px").end().find("th:nth-child(5) > label").text(d),0==g.length&&h.appendTo("#sis-regen .wrapper > table#sis_sizes > tbody"),h.removeClass("errorAdding notChangedAdding successAdding").addClass(e),clearTimeout(f),f=setTimeout(function(){h.removeClass("errorAdding notChangedAdding successAdding")},3e3)},removeFromArray:function(a){var b=jQuery(a).closest("tr").find("input[name=image_name]").val();jQuery("#sis-"+b).remove()},displayChange:function(a){var a=jQuery(a),b=a.closest("tr");if(b.hasClass("new_size"))return!1;var c=b.find("input.h"),d=b.find("input.w"),e=b.find("select.c"),f=b.find("input.s"),g=b.find("input.n"),h=c.val(),i=d.val(),j=e.val(),k=f.val(),l=g.val(),m=c.attr("base_h"),n=d.attr("base_w"),o=e.attr("base_c"),p=f.attr("base_s"),q=g.attr("base_n");o="0"==o?!1:!0,p="0"==p?!1:!0,h!=m||i!=n||j!=o||k!=p||l!=q?a.closest("td").addClass("notSaved").find(".add_size").css("display","inline-block"):a.closest("td").removeClass("notSaved").find(".add_size").css("display","none")}},rahe.sis.template=_.memoize(function(a){var b,c={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"};return function(d){return(b=b||_.template(jQuery("#sis-"+a).html(),null,c))(d)}}),jQuery(function(){rahe.sis.regenerate.init();var a=jQuery("#wpbody-content");jQuery("#ajax_thumbnail_rebuild").click(function(){rahe.sis.regenerate.checkStartRegenerating()}),a.on("click","#add_size",function(a){rahe.sis.sizes.add(a,this)}).on("click",".add_size_name",function(a){rahe.sis.sizes.register(a,this)}).on("click",".delete_size",function(a){rahe.sis.sizes.deleteSize(a,this)}).on("click",".add_size",function(a){rahe.sis.sizes.ajaxRegister(a,this)}).on("click keyup change",".h,.w,.c,.s,.n",function(){rahe.sis.sizes.displayChange(this)}).on("click","#get_php",function(a){rahe.sis.sizes.getPhp(a,this)}),jQuery("#get_php").nextAll("code").hide(),jQuery(".add_size").hide()});
classes/admin/media.php CHANGED
@@ -390,6 +390,8 @@ Class SIS_Admin_Media {
390
  FROM $wpdb->posts
391
  WHERE post_type IN ('".implode( "', '", $_POST['post_types'] )."')
392
  )" );
 
 
393
 
394
  } else {
395
  $attachments = get_children( array(
@@ -400,10 +402,10 @@ Class SIS_Admin_Media {
400
  'post_parent' => null, // any parent
401
  'output' => 'ids',
402
  ) );
 
 
403
  }
404
 
405
- // Return the Id's and Title of medias
406
- SIS_Admin_Main::displayJson( array( 'total' => count( $attachments ) ) );
407
  }
408
 
409
  /**
@@ -422,7 +424,7 @@ Class SIS_Admin_Media {
422
 
423
  // Check the nonce
424
  if( !wp_verify_nonce( $nonce , 'regen' ) ) {
425
- SIS_Admin_Main::displayJson( array( 'error' => _e( 'Trying to cheat ?', 'simple-image-sizes' ) ) );
426
  }
427
 
428
  if ( $post_types !== 'any' ) {
@@ -433,7 +435,7 @@ Class SIS_Admin_Media {
433
  }
434
  }
435
 
436
- if( empty( $_POST['post_types'][$key]) ) {
437
  SIS_Admin_Main::displayJson();
438
  }
439
 
@@ -474,4 +476,4 @@ Class SIS_Admin_Media {
474
  }
475
  SIS_Admin_Main::displayJson( SIS_Admin_Main::thumbnail_rebuild( $attachment, $thumbnails ) );
476
  }
477
- }
390
  FROM $wpdb->posts
391
  WHERE post_type IN ('".implode( "', '", $_POST['post_types'] )."')
392
  )" );
393
+ // Return the Id's and Title of medias
394
+ SIS_Admin_Main::displayJson( array( 'total' => $attachments ) );
395
 
396
  } else {
397
  $attachments = get_children( array(
402
  'post_parent' => null, // any parent
403
  'output' => 'ids',
404
  ) );
405
+ // Return the Id's and Title of medias
406
+ SIS_Admin_Main::displayJson( array( 'total' => count( $attachments ) ) );
407
  }
408
 
 
 
409
  }
410
 
411
  /**
424
 
425
  // Check the nonce
426
  if( !wp_verify_nonce( $nonce , 'regen' ) ) {
427
+ SIS_Admin_Main::displayJson( array( 'error' => __( 'Trying to cheat ?', 'simple-image-sizes' ) ) );
428
  }
429
 
430
  if ( $post_types !== 'any' ) {
435
  }
436
  }
437
 
438
+ if( empty( $_POST['post_types'] ) ) {
439
  SIS_Admin_Main::displayJson();
440
  }
441
 
476
  }
477
  SIS_Admin_Main::displayJson( SIS_Admin_Main::thumbnail_rebuild( $attachment, $thumbnails ) );
478
  }
479
+ }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Rahe
3
  Donate link: http://www.beapi.fr/donate/
4
  Tags: images, image, custom sizes, custom images, thumbnail regenerate, thumbnail, regenerate
5
  Requires at least: 3.5
6
- Tested up to: 3.9
7
- Stable tag: 3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -48,6 +48,11 @@ And then you can choose if the image is displayed on the media insertion or not
48
  3. Choose the sizes to regenerate and regenerate them
49
 
50
  == Changelog ==
 
 
 
 
 
51
  * 3.0
52
  * Revamping all the code, change classes and structure
53
  * Use grunt for compiling files
3
  Donate link: http://www.beapi.fr/donate/
4
  Tags: images, image, custom sizes, custom images, thumbnail regenerate, thumbnail, regenerate
5
  Requires at least: 3.5
6
+ Tested up to: 4.0
7
+ Stable tag: 3.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
48
  3. Choose the sizes to regenerate and regenerate them
49
 
50
  == Changelog ==
51
+ * 3.0.1
52
+ * Change the template render method for non apache webservers : https://wordpress.org/support/topic/fatal-error-1190?replies=6
53
+ * Remove ambigious ids for the css bugging WooCommerce : https://wordpress.org/support/topic/bad-css-style-administration and
54
+ * Right code for counting the elements on backoffice : https://github.com/Rahe/Simple-image-sizes/issues/20
55
+ * Fix bug on regenation and _e instead of __ : https://plugins.trac.wordpress.org/ticket/2259
56
  * 3.0
57
  * Revamping all the code, change classes and structure
58
  * Use grunt for compiling files
simple_image_sizes.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Simple Image Sizes
4
  Plugin URI: https://github.com/Rahe/'simple-image-sizes'
5
  Description: Add options in media setting page for images sizes
6
- Version: 3.0
7
  Author: Rahe
8
  Author URI: http://nicolas-juen.fr
9
  Text Domain: 'simple-image-sizes'
@@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30
 
31
  define( 'SIS_URL', plugin_dir_url ( __FILE__ ) );
32
  define( 'SIS_DIR', plugin_dir_path( __FILE__ ) );
33
- define( 'SIS_VERSION', '3.0' );
34
  define( 'SIS_OPTION', 'custom_image_sizes' );
35
 
36
  // Function for easy load files
3
  Plugin Name: Simple Image Sizes
4
  Plugin URI: https://github.com/Rahe/'simple-image-sizes'
5
  Description: Add options in media setting page for images sizes
6
+ Version: 3.0.1
7
  Author: Rahe
8
  Author URI: http://nicolas-juen.fr
9
  Text Domain: 'simple-image-sizes'
30
 
31
  define( 'SIS_URL', plugin_dir_url ( __FILE__ ) );
32
  define( 'SIS_DIR', plugin_dir_path( __FILE__ ) );
33
+ define( 'SIS_VERSION', '3.0.1' );
34
  define( 'SIS_OPTION', 'custom_image_sizes' );
35
 
36
  // Function for easy load files
templates/admin-js.html CHANGED
@@ -1,47 +1,47 @@
1
  <script type="text/html" id="sis-new_size">
2
- <tr valign="top" class="new_size_<%= size_id %> new_size">
3
  <th scope="row">
4
- <input type="text" id="new_size_<%= size_id %>" value="thumbnail-name">
5
  </th>
6
  <td>
7
- <input type="button" id="validate_<%= size_id %>" value="<%= validate %>" class="button-secondary action add_size_name">
8
  </td>
9
  </tr>
10
  </script>
11
  <script type="text/html" id="sis-new_size_row">
12
- <th scope="row"><%= size %><%= size_name %></th>
13
  <td>
14
- <input type="hidden" name="image_name" value="<%= size_name %>">
15
- <input type="hidden" name="custom_image_sizes[<%= size_name %>][custom]" value="1">
16
- <label for="custom_image_sizes[<%= size_name %>][w]" class="sis-label">
17
- <%= maximumWidth %>
18
- <input type="number" name="custom_image_sizes[<%= size_name %>][w]" value="1" step="1" min="0" id="custom_image_sizes[<%= size_name %>][w]" base_w="0" class="w small-text">
19
  </label>
20
- <label for="custom_image_sizes[<%= size_name %>][h]" class="sis-label">
21
- <%= maximumHeight %>
22
- <input type="number" name="custom_image_sizes[<%= size_name %>][h]" value="1" step="1" min="0" id="custom_image_sizes[<%= size_name %>][h]" base_h="0" class="h small-text">
23
  </label>
24
- <label for="custom_image_sizes[<%= size_name %>][n]" class="sis-label">
25
- <%= customName %>
26
- <input type="text" name="custom_image_sizes[<%= size_name %>][n]" id="custom_image_sizes[<%= size_name %>][n]" base_n="<%= size_name %>" class="n">
27
  </label>
28
  <span class="size_options">
29
- <label for="custom_image_sizes[<%= size_name %>][c]" id="custom_image_sizes[<%= size_name %>][c]" class="c" title="<%= crop %>">
30
- <%= crop %>
31
  </label>
32
- <select type="checkbox" name="custom_image_sizes[<%= size_name %>][c]" id="custom_image_sizes[<%= size_name %>][c]" base_c="0" class="c crop">
33
- <option value="0"> <%- sis.fl %> </option>
34
- <option value="1"> <%- sis.tr %> </option>
35
- <% _.each( sis.crop_positions, function( label, name ) { %>
36
- <option value="<%- name %>"> <%- label %> </option>
37
- <% }); %>
38
  </select>
39
- <input type="checkbox" name="custom_image_sizes[<%= size_name %>][s]" id="custom_image_sizes[<%= size_name %>][s]" base_s="0" value="1" class="s show">
40
- <label for="custom_image_sizes[<%= size_name %>][s]" id="custom_image_sizes[<%= size_name %>][s]" class="s" title="<%= show %>">
41
- <%= show %>
42
  </label>
43
  </span>
44
- <div class="delete_size button-secondary"><%= deleteImage %></div>
45
- <div class="add_size button-secondary"><%= validateButton %></div>
46
  </td>
47
  </script>
1
  <script type="text/html" id="sis-new_size">
2
+ <tr valign="top" class="new_size_{{ data.size_id }} new_size">
3
  <th scope="row">
4
+ <input type="text" id="new_size_{{ data.size_id }}" value="thumbnail-name">
5
  </th>
6
  <td>
7
+ <input type="button" id="validate_{{ data.size_id }}" value="{{ data.validate }}" class="button-secondary action add_size_name">
8
  </td>
9
  </tr>
10
  </script>
11
  <script type="text/html" id="sis-new_size_row">
12
+ <th scope="row">{{ data.size }}{{ data.size_name }}</th>
13
  <td>
14
+ <input type="hidden" name="image_name" value="{{ data.size_name }}">
15
+ <input type="hidden" name="custom_image_sizes[{{ data.size_name }}][custom]" value="1">
16
+ <label for="custom_image_sizes[{{ data.size_name }}][w]" class="sis-label">
17
+ {{ data.maximumWidth }}
18
+ <input type="number" name="custom_image_sizes[{{ data.size_name }}][w]" value="1" step="1" min="0" id="custom_image_sizes[{{ data.size_name }}][w]" base_w="0" class="w small-text">
19
  </label>
20
+ <label for="custom_image_sizes[{{ data.size_name }}][h]" class="sis-label">
21
+ {{ data.maximumHeight }}
22
+ <input type="number" name="custom_image_sizes[{{ data.size_name }}][h]" value="1" step="1" min="0" id="custom_image_sizes[{{ data.size_name }}][h]" base_h="0" class="h small-text">
23
  </label>
24
+ <label for="custom_image_sizes[{{ data.size_name }}][n]" class="sis-label">
25
+ {{ data.customName }}
26
+ <input type="text" name="custom_image_sizes[{{ data.size_name }}][n]" id="custom_image_sizes[{{ data.size_name }}][n]" base_n="{{ data.size_name }}" class="n">
27
  </label>
28
  <span class="size_options">
29
+ <label for="custom_image_sizes[{{ data.size_name }}][c]" id="custom_image_sizes[{{ data.size_name }}][c]" class="c" title="{{ data.crop }}">
30
+ {{ data.crop }}
31
  </label>
32
+ <select type="checkbox" name="custom_image_sizes[{{ data.size_name }}][c]" id="custom_image_sizes[{{ data.size_name }}][c]" base_c="0" class="c crop">
33
+ <option value="0"> {{ sis.fl }} </option>
34
+ <option value="1"> {{ sis.tr }} </option>
35
+ <# _.each( sis.crop_positions, function( label, name ) { #>
36
+ <option value="{{ name }}"> {{ label }} </option>
37
+ <# }); #>
38
  </select>
39
+ <input type="checkbox" name="custom_image_sizes[{{ data.size_name }}][s]" id="custom_image_sizes[{{ data.size_name }}][s]" base_s="0" value="1" class="s show">
40
+ <label for="custom_image_sizes[{{ data.size_name }}][s]" id="custom_image_sizes[{{ data.size_name }}][s]" class="s" title="{{ data.show }}">
41
+ {{ data.show }}
42
  </label>
43
  </span>
44
+ <div class="delete_size button-secondary">{{ data.deleteImage }}</div>
45
+ <div class="add_size button-secondary">{{ data.validateButton }}</div>
46
  </td>
47
  </script>
templates/options-media.php CHANGED
@@ -110,8 +110,8 @@
110
  </table>
111
  </div>
112
  </div>
113
- <div >
114
- <div id="regenerate_message"></div>
115
  <div class="media-item sis">
116
  <div class="progress">
117
  <div id="sis_progress-percent" class="percent">100%</div>
@@ -119,7 +119,7 @@
119
  </div>
120
  </div>
121
 
122
- <div class="ui-widget" id="time">
123
  <div class="ui-state-highlight ui-corner-all">
124
  <p>
125
  <span class="ui-icon ui-icon-info"></span>
@@ -134,6 +134,6 @@
134
  </ol>
135
  </p>
136
  </div>
137
- <div id="thumb"><h4><?php _e( 'Last image:', 'simple-image-sizes'); ?></h4><img id="thumb-img" /></div>
138
  <input type="button" class="button" name="ajax_thumbnail_rebuild" id="ajax_thumbnail_rebuild" value="<?php _e( 'Regenerate Thumbnails', 'simple-image-sizes' ) ?>" />
139
  </div>
110
  </table>
111
  </div>
112
  </div>
113
+ <div class="sis" >
114
+ <div class="regenerate_message"></div>
115
  <div class="media-item sis">
116
  <div class="progress">
117
  <div id="sis_progress-percent" class="percent">100%</div>
119
  </div>
120
  </div>
121
 
122
+ <div class="ui-widget time">
123
  <div class="ui-state-highlight ui-corner-all">
124
  <p>
125
  <span class="ui-icon ui-icon-info"></span>
134
  </ol>
135
  </p>
136
  </div>
137
+ <div class="thumb"><h4><?php _e( 'Last image:', 'simple-image-sizes'); ?></h4><img class="thumb-img" /></div>
138
  <input type="button" class="button" name="ajax_thumbnail_rebuild" id="ajax_thumbnail_rebuild" value="<?php _e( 'Regenerate Thumbnails', 'simple-image-sizes' ) ?>" />
139
  </div>