Tell me more ×
SmugMug Stack Exchange is a question and answer site for SmugMug developers and end users. It's 100% free, no registration required.

Say the image's ID is "imageid" and the Key is "imagekey". What's the magical formula to produce a url to view the image? What other options do I have at the time?

share|improve this question

2 Answers

up vote 11 down vote accepted

The short answer is you shouldn't be programmatically constructing URLs. I know, I hate that answer too as it can lead to either heavy requests or lots of subsequent requests.

However (Muhahah) you can provide 'CustomSize' as an argument to smugmug.images.get and it'll return the correct URL to fetch that custom size, the argument works as CustomSize=640x640:

http://api.smugmug.com/services/api/json/1.3.0/?method=smugmug.images.get&AlbumID=5363890&AlbumKey=GxmcTJ&APIKey=kYMUWW4JPOqH2ahgqAGEs8fsdkbzlEHt&Pretty=1&CustomSize=640x640

which returns:

  ....
  {
    "id": 743610869,
    "Key": "hiPob",
    "CustomURL": "http://cmac.smugmug.com/SmugMug/Marketing-shots/SmugMug-homepage-slide-show/MarcMuench/743610869_hiPob-640x640-1.jpg"
  },
  {
    "id": 743634929,
    "Key": "tGx5h",
    "CustomURL": "http://cmac.smugmug.com/SmugMug/Marketing-shots/SmugMug-homepage-slide-show/JohnHarrison/743634929_tGx5h-640x640.jpg"
  },
  ....

Now, if you want to be able to sub in a custom size at any time after the fact just put in some specific custom size and do a replace on that like CustomSize=5031337x5031337 :)

share|improve this answer
Excellent, this answered my subsequent questions. – Jordan H. Mar 22 '12 at 13:42
In the same vein, you can also set Heavy=True, which sends back all manner of URLs... medium, large, small, thumb, tiny... including just a plain ol' URL – mblackwell8 Jan 31 at 11:27

As is usually the case, the answer came right after I posted the question!

Using image ID "imageid" and image Key "imagekey", the following URL gives me what I want:

http://photos.smugmug.com/photos/imageid_imagekey.jpg

Looks like the sizing instructions you can find elsewhere work here, too. So...

http://photos.smugmug.com/photos/250x250/imageid_imagekey-250x250.jpg

also works nicely.

I marked this as "community wiki" in case there are other options that anyone would like to add!

share|improve this answer
Just keep in mind not all images are accessed via imageid and imagekey, thats the 'old' url style, new urls look like : sams.smugmug.com/Other/617/i-NhKqsNT/0/X3/lamp-X3.jpg – Shizam Mar 19 '12 at 15:16
That's a good point. In the case where the new URLs are in effect, how do you construct the URL for a custom size without grabbing one of the predefined URLs and modifying it in code? – Jordan H. Mar 19 '12 at 16:21
1  
@Jordan if you are already using the api, why not use the smugmug.images.getURLs (wiki.smugmug.net/display/API/…) method? – jschoen Mar 20 '12 at 20:10
Actually didn't realize that function existed. :-) But, I like to avoid extra calls where possible, and it looks like I'd have to do that once for each image in an album (which is why I wanted to flesh out the "equation" for different sizes). Thanks for pointing out that function! – Jordan H. Mar 21 '12 at 21:37
1  
I downvoted this answer because you shouldn't do it like this :) Also, I don't think this should be part of the wiki, this is a very valid question that a lot of devs would ask. – Shizam Mar 22 '12 at 0:55
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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