48 Responses

  1. donnacha WordSkill
    donnacha WordSkill Published |

    Thanks, that’s incredibly useful for something I’m working on, giving Flickr-style size options hadn’t even occurred to me.

  2. Randy
    Randy Published |

    (Quote)WordPress is still lacking in some ways when it comes to handling media.
    Oh, do you mean like when they output style tags right into the body so the page doesn’t validate? ha!

    Great information. I am always trying to find better ways to work with WP’s image attachments. I try not to use gallery plugins and would rather output everything on my own, then incorporate that output into a gallery or presentation system of my choosing.

    For example: Recently, I had to split all the image attachments for a post into before and after pics and this little tip could have made it even more slick. Oh well. Next time.

    BTW – Does this also find any add_image_size custom sizes or just the sizes set in the media settings?

    1. Randy
      Randy Published |

      As soon as I posted I saw the plugin in your sidebar! Thanks!

  3. Emil
    Emil Published |

    Wow this is amazing, good job as always.


  4. Michael Beckwith
    Michael Beckwith Published |

    Justin, this is a perfect example of what I could use for some client sites that I’ve worked on that have been utilizing featured images. We have worried a bit about what image gets pulled with the possible range of sizes a client may upload. Using the information you showed above, I could make sure we likely pull the necessary one and not break the website layout.

  5. Jamal Mohamed
    Jamal Mohamed Published |

    I wonder where you get these crazy ideas, Justin! Awesome as usual.

  6. Andre
    Andre Published |

    Is there any way to put all formats when we insert an image in the post (in lightbox upload)?

    For example: http://img15.imageshack.us/img15/2844/helpwr.jpg


  7. max
    max Published |

    Hi justin, thanks for great function.., i just want to ask is there any way to make the image link that we click will be open up in image.php page… what i mean something like this :

    Size : 150×150 , 300×300..etc

    From your function, if i click 150×150.., then it goes to myimage-150×150.jpg..
    I just wondering if you could make it appear in image.php if i click 150×150.. not to image location..

    the link maybe like this :
    Original image.php link

    If click on 150×150 goes to here :

    Can it be done..?

    1. aan
      aan Published |

      Great question!

      Bump this question since this isn’t answered yet and I have the same question, how to link to attachment with resized image from add size function.


  8. Navin
    Navin Published |

    Thanks Justin, I will impleament this in my blog…thanks alot for sharing 🙂

  9. Heather
    Heather Published |

    Is there any working example? I would love to see it, it can be interesting demonstration to show my designers (if I understand correctly what you describe). We launched a new WP site few weeks ago, but handling pictures (since there have been and will be many listings added) has been always challenge.

  10. Kiley
    Kiley Published |

    Hey Justin, yeah you were right. I’ve been using it. You can add the link not Flickr links only but anywhere you wanted your images to be redirected once clicked. This gave more ideas to those who were not doing this yet.

  11. Linking to all image sizes in WordPress | Mark Wilkinson on WordPress
  12. eddy
    eddy Published |

    This is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you (not that I really would want…hehe). You definitely put a new spin on a subject that’s been written about for years. Great stuff, just great!

  13. Herman
    Herman Published |

    I would like to see an example,looks interesting.

  14. Ross
    Ross Published |

    Hi Justin

    Thanks for the info, I’ve been looking for a fix like this! Shall be implementing it this afternoon once I’ve gotten some coffee in me…. always a nervous time when changing CSS. Shall be doing much backing up first! Fingers crossed



  15. Inviting Your Opinions for Photo Blogging Support » Aquoid Themes
  16. Shehzad
    Shehzad Published |

    Been trying to do this for a while, thanks for the excellent post, will try it and let you know how it goes.

  17. Danny Pras
    Danny Pras Published |

    I should try it, it would be nice to have this in wordpress, going to digg it up more.

  18. Tim McCullen
    Tim McCullen Published |

    OMG Justin thanks you for this post. This is EXACTLY what I was looking for on our new site. Posted to Twitter. THANK YOU!

  19. AJ Clarke
    AJ Clarke Published |

    This is a sweet piece of code. I’m thinking this could be integrated really nicely with some sort of image gallery plugin on a photography style site. I will give this one a try. Thanks Justin!

  20. Mark
    Mark Published |

    That is a good code for wordpress. One thing I’m trying to do is making lightbox work only on attachment page, anyone tried that?

  21. 21 Fresh WordPress Code Snippets and Detailed Tutorials
  22. Inviting Your Opinions for Photo Blogging Support » Aquoid Themes
  23. Will
    Will Published |

    Excellent – I was looking all over for this and didn’t find it in the WP documentation. Thanks.

  24. Gary Taylor
    Gary Taylor Published |

    Once again, Justin, you deliver the goods!

    I’m developing a site for work, which will be a photo library. Wordpress resizes the images, and users can select a size for print, embedding or using as a thumbnail for our various sites (with various sizes – and yes, custom sizes work).

    Next step is to adapt your code to have have them linked by named size-types rather than their dimensions, and to exclude the thumbnail built-in size (because that’s used only by this site). Suspect the latter will be easier than the former – just need to exclude item [0] from the array…


  25. Alex
    Alex Published |

    Justin thanks you for this post. I wonder where you get these crazy ideas!

  26. Rafael Trabasso
    Rafael Trabasso Published |

    Congratulations, I was wondering if someone has already done this.
    Then I googled “Wordpress all image sizes”… : )

  27. Jake
    Jake Published |

    Thank you for this post, incredibly helpful.

  28. Pauro
    Pauro Published |

    Thank you Justin, helpful as usual.
    Next step, I think it would be better to limit appeared sizes into full-large-middle only. The reason is, I don’t think anybody wants to click small 150×150 thumbnail, so I think it would be better if we can limit the sizes. Can you help to do this?

  29. Martin Allien
    Martin Allien Published |

    Oh, this is amazing! As many others here, I really need this function and you made my life a lil’ easier :]

    Thanks and have a nice day!

  30. Rabin
    Rabin Published |

    Is there any way to show the size for all images in the post? or even when using the [gallery] shortcode?
    If this can be done then please let us know, it will help me a lot.

  31. Paul
    Paul Published |

    I would also be very interrested to hear how this should be implemented in a lightbox on ordinary pages.

    Kind regards

  32. dann
    dann Published |

    thanks, this really helped!!

  33. Mike
    Mike Published |

    Is there a way to display category name and tags list at attachment page?

  34. Piet
    Piet Published |

    Although super useful code above, the post actually deals with image dimensions, not the size (as in bytes).

    Would you by any chance know of a good way to echo the file size (in bytes) on the single attachment page?

    Many thanks in advance.

  35. Stew
    Stew Published |

    Not work for me, i’ve placed the code in the loop but no link show, please can help?

  36. Harry Saggu
    Harry Saggu Published |

    Not working on my wp site ….. i can’t find image.php or attached.php page in my website directory.
    can you please help me to show this amazing feature on custom place.


  37. Darshak Parmar
    Darshak Parmar Published |

    Excellent piece of code. many thanks for that. Has anyone tried using this to show available sizes right below the images within a post and not on attachment pages?

    1. Anty
      Anty Published |

      Did you get this to work for posts?

  38. Display All Image Sizes of Attached Image in WordPress - WPSnippy
  39. Usman
    Usman Published |

    The result is showing randomly not in sorting order From Low to High Resolution. Please correct it or tell me where to change the code get sorted result.

    150 × 150 / 300 × 225 / 1024 × 768 / 780 × 400 / 374 × 200 / 239 × 130 / 75 × 75 / 1152 × 864


Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution.

Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.