Skip to main content
18 events
when toggle format what by license comment
Dec 3, 2012 at 13:46 comment added Amanda Duke Excellent, works very well. I was going with this dummy solution prior to your fix: foreach ( (array) $attach_meta['sizes'] as $size => $value) { Thanks again for the very quick support!
Dec 3, 2012 at 13:41 comment added Ahmad M @AmandaDuke: Both blocks of code have been updated. The first block was before: if ( $post->post_mime_type == 'image/jpeg' ) and now it is if ( $post->post_mime_type == 'image/jpeg' && is_array($attach_meta['sizes']) )
Dec 3, 2012 at 13:23 comment added Amanda Duke @AhmadM Ah I noticed that you updated the plugin, but not the code you have above the plugin - which is the one that I was using. Is there any chance that you can update that one too?
Dec 3, 2012 at 13:11 comment added Amanda Duke @AhmadM Thank you very much for detailing the solution. Works perfectly.
Dec 2, 2012 at 20:33 history edited Ahmad M CC BY-SA 3.0
added 35 characters in body
Dec 2, 2012 at 20:22 history edited Ahmad M CC BY-SA 3.0
added 35 characters in body
Dec 2, 2012 at 20:18 comment added Ahmad M @AmandaDuke Thanks for pointing that out. This error happen because $attach_meta['sizes'] is expected to be an array while in this case it is not. In most cases it should and this can only happen if we dont have custom image sizes and we don't specify the default image sizes in Settings -> Media Settings. To be safe and make sure we have an array we can add a check before passing it to the foreach loop: if (is_array($attach_meta['sizes'])). Please see the updated code.
Dec 2, 2012 at 16:29 comment added Amanda Duke @Ahmad there is a bug in your code. When uploading an image, if it is smaller than the dimensions of the smallest custom image size, then this error appears: Invalid argument supplied for foreach(). So basically, when no custom image is made, the error appears. Do you know how to fix this problem?
Dec 1, 2012 at 17:53 vote accept Amanda Duke
Dec 1, 2012 at 17:53 comment added Amanda Duke Outstanding answer Ahmad. I tested it and it works fine (although didn't test the plugin as I do not need to change old images). Upvoted and accepted.
Nov 29, 2012 at 16:19 comment added brasofilo The "share" link just bellow the question provides a short url that contains your user id. That's useful for some badges ;)
Nov 29, 2012 at 16:12 comment added Ahmad M @brasofilo: Thanks for the advice, just updated accordingly.
Nov 29, 2012 at 16:11 comment added Ahmad M @AmandaDuke: You can extend the if statement by elseif. See my update.
Nov 29, 2012 at 16:10 history edited Ahmad M CC BY-SA 3.0
added 394 characters in body
Nov 29, 2012 at 15:55 comment added brasofilo +1 Great Answer! You could use the Question link as Plugin URI and your profile as Author URI...
Nov 29, 2012 at 15:55 comment added Amanda Duke This is a very interesting reply. How do I add both 'splash1' and 'splash2' to the IF statement?: if ($size == 'splash')...
Nov 29, 2012 at 15:53 history edited Ahmad M CC BY-SA 3.0
deleted 3 characters in body
Nov 29, 2012 at 15:48 history answered Ahmad M CC BY-SA 3.0