Supposing that we know nothing except the url of image (smaller size e.g. 150x150)


What is the best way to get its full-size image url from the url above?


Just easily remove the prefix "-150x150" ? (I'm not sure if this is proper since i need best practice also.)

  • Yes, that is correct :-)
    – Matt Royal
    Commented Jun 30, 2014 at 11:39
  • You can get the ID from the URL by using the method shown here. After you have the ID available you can use it get the information you want. Commented Jun 30, 2014 at 12:15
  • @ialocin Thanks for suggestion. However, that seems over-complicated to me ;( Commented Jun 30, 2014 at 15:26
  • @MattRoyal Hey, are you really ok with just removing "-150x150" suffix? lol Commented Jun 30, 2014 at 15:27
  • @AtthaponJunpun-eak, seeing as though the URL is always appended using that convention, I have never had a problem with it ;-)
    – Matt Royal
    Commented Jun 30, 2014 at 15:57

1 Answer 1


The URL for rezied images in WordPress is constructed in a way that's impossible to direct reverse. Therefore, it's impossible to get the attachment associated with a URL of a resized image with 100% certainty, unless you loop through all attachments and check whether their URL matches the given URL. However, this approach is very slow and resource-intensive.

In any normal WordPress setup, you can rest assured that, given a URL of a resized image, you can retrieve the full image URL by removing the dimensions from the URL. This is, however strange it may seem, best practice.

  • Thanks for your explanation. This really confirms my thought about removing dimension suffix. Marked as answer though. ;) Commented Jun 30, 2014 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.