Random image API requests

ReevesReeves Registered Users Posts: 17 Big grins
Howdy folks,

OneThumb pointed out in the API thread that there is random image via URL API for pulling a random image of a particular size from a given gallery (very cool, I'm going to start using that :):).

I do, however, have two requests for variations on that API:
  1. The first request is the same request as TazzyTazzy: be able to pull a random image from my entire site. I'd love to have a random image from my galleries featured on my blog.
  2. The second request is to be able to pull a random image from a keyword gallery. I have a "favorites" gallery put into my featured section (details on the hack) but the image is hard coded. I'd like to have the gallery preview thumbnail rotate like those of other galleries.
Thanks again to the folks at SmugMug for creating such an awesome product!

Cheers,
Reeves

Comments

  • richpepprichpepp Registered Users Posts: 360 Major grins
    edited October 27, 2006
    Thanks for the link Reeves. That URL for a random image was exactly what I was looking for. I would also second your request for a similar URL that would allow you to pull a random photo from your site by keyword. I've all seen a lot of useful code here that would allow me to generate a random image if I hard code a list of images but a URL would be awesome.

    tx to all who help here

    Rich
  • BeachBillBeachBill Registered Users Posts: 1,311 Major grins
    edited October 31, 2006
    Anyone know how to get it to work?

    I've try with a few different gallery IDs, all resulting in "Photo Not Found".

    For example, viewing
    http://www.smugmug.com/photos/random.mg?AlbumID=1340265&Size=SMUGSIZE
    results in
    http://williams.smugmug.com/img/imagenotfound-Tiny.gif

    http://www.smugmug.com/photos/random.mg?AlbumID=1842802&Size=SMUGSIZE
    results in
    http://primarycolors.smugmug.com/img/imagenotfound-Tiny.gif

    It's finding the right smugmug site for the gallery ID provided, but it's not finding any images... ne_nau.gif
    Bill Gerrard Photography - Facebook - Interview - SmugRoom: Useful Tools for SmugMug
  • onethumbonethumb Administrators Posts: 1,269 Major grins
    edited November 3, 2006
    BeachBill wrote:
    Anyone know how to get it to work?

    I've try with a few different gallery IDs, all resulting in "Photo Not Found".

    For example, viewing
    http://www.smugmug.com/photos/random.mg?AlbumID=1340265&Size=SMUGSIZE
    results in
    http://williams.smugmug.com/img/imagenotfound-Tiny.gif

    http://www.smugmug.com/photos/random.mg?AlbumID=1842802&Size=SMUGSIZE
    results in
    http://primarycolors.smugmug.com/img/imagenotfound-Tiny.gif

    It's finding the right smugmug site for the gallery ID provided, but it's not finding any images... ne_nau.gif

    Hey BeachBill,

    I'll bet your issue is that you're not replacing "SMUGSIZE" with a valid SmugMug size (Tiny, Thumb, Small, Medium, Large, Original).

    I think custom pixel render targets work, too, so you could specify "300x300" instead of a size to get a pic that's 300px on it's longest side.

    Don
  • BeachBillBeachBill Registered Users Posts: 1,311 Major grins
    edited November 3, 2006
    onethumb wrote:
    Hey BeachBill,

    I'll bet your issue is that you're not replacing "SMUGSIZE" with a valid SmugMug size (Tiny, Thumb, Small, Medium, Large, Original).

    I think custom pixel render targets work, too, so you could specify "300x300" instead of a size to get a pic that's 300px on it's longest side.

    Don

    Oh, I didn't know that SMUGSIZE had to be replaced by anything. That was evident from the posting I took this from (http://www.dgrin.com/showpost.php?p=334753&postcount=3)

    It works good now that I know what I'm doing! clap.gif

    Thanks!
    Bill Gerrard Photography - Facebook - Interview - SmugRoom: Useful Tools for SmugMug
  • xxclixxxxxclixxx Registered Users Posts: 91 Big grins
    edited March 24, 2007
    I'll second and third the random keyword image api.

    /photos/random.mg?Keyword=lighthouse&Size=150x150

    It would be really awesome if I could use that instead of having to create an album just for lighthouses to display a random lighthouse. Until then I guess I'll just have to keep doing it this way.
    Tim Linden
    http://www.riphoto.com/
    Please Vote - External Shopping Cart Links:
    http://uservoice.com/a/mL8RD
  • ChibiPhotographyChibiPhotography Registered Users Posts: 30 Big grins
    edited May 27, 2007
    Custom size / custom crop?
    onethumb wrote:
    Hey BeachBill,

    I'll bet your issue is that you're not replacing "SMUGSIZE" with a valid SmugMug size (Tiny, Thumb, Small, Medium, Large, Original).

    I think custom pixel render targets work, too, so you could specify "300x300" instead of a size to get a pic that's 300px on it's longest side.

    Don

    The custom size render feature is cool, is it also possible to have a custom crop applied?

    For example:
    /photos/%photoid%-150x100-crop.jpg

    Which would give a 150x100
    cropped image.

    I would like this feature to be able to build graphic elements dynamicly.

    Doug
    Doug Pearson
    Chibi Photography
    pix.chibiphotography.com
  • jmck04jmck04 Registered Users Posts: 2 Beginner grinner
    edited July 10, 2007
    Hmm, looks like a common theme, being able to grab a random photo from any gallery. If we're asking for features then I would like to include the ability to grab one from any category as well as by keyword. We have a site that does things by years and I'd like to be able to grab from the current year.

    Anyhow, for now the way I get around this is right now is with a little PHP script. I create a file that contains a list of galleries and I grab a random gallery number from that and stick that into a dynamically generated URL. I have some extra information so I can select a specific gallery for certain pages if I want to. The file makes this easier because if something changes it's all in one place.

    I think the API would let me do this on the fly, but I haven't got that far into that part of it yet.

    If I get a second I'll dig it out and post it.

    thanx
    -jmck
  • FormerLurkerFormerLurker Registered Users Posts: 82 Big grins
    edited September 3, 2007
    jmck04 wrote:
    Hmm, looks like a common theme, being able to grab a random photo from any gallery. If we're asking for features then I would like to include the ability to grab one from any category as well as by keyword. We have a site that does things by years and I'd like to be able to grab from the current year.

    Anyhow, for now the way I get around this is right now is with a little PHP script. I create a file that contains a list of galleries and I grab a random gallery number from that and stick that into a dynamically generated URL. I have some extra information so I can select a specific gallery for certain pages if I want to. The file makes this easier because if something changes it's all in one place.

    I think the API would let me do this on the fly, but I haven't got that far into that part of it yet.

    If I get a second I'll dig it out and post it.

    thanx
    -jmck

    Since I can't seem to get a random image selected by keyword, I was going to do exactly the same thing with the php script. That was my project for today. If you're happy with your code and are willing to share, I'd be greatful for the assist.
  • NimaiNimai Registered Users Posts: 564 Major grins
    edited September 18, 2007
    Wha-!!?
    I just assumed random.mg had a keyword-based mode! mur.gif

    Haha- OK, I'm not going to be that dramatic. I could really use this simple feature.
    I've got three local scools in one gallery, differentiated by keywords. I wanted to put a random.mg img tag on the website for one of the schools, but I would need a Keyword CGI parameter. C'mon guys- that would take you, what... all of 10 minutes?
    <a href="http://denise.smugmug.com/gallery/3260851">
    <img src="http://denise.smugmug.com/photos/random.mg?Keyword=WHS-cheerleading-2007&Size=275x275"></a>
    
    Let's make that code work^^^
    Consider it thrown
    gauntletmy3.gif
  • NimaiNimai Registered Users Posts: 564 Major grins
    edited September 21, 2007
    Until there's an official way to do it, I've got an unofficial way [thread=71808]here[/thread] if you've got a server to put a PHP sript on.
  • paigewpaigew Registered Users Posts: 2 Beginner grinner
    edited January 31, 2008
    jmck04 wrote:
    Anyhow, for now the way I get around this is right now is with a little PHP script. I create a file that contains a list of galleries and I grab a random gallery number from that and stick that into a dynamically generated URL. I have some extra information so I can select a specific gallery for certain pages if I want to. The file makes this easier because if something changes it's all in one place.

    I am currently doing this in C# for a DotNetNuke module I'm creating. I am using Evan Leventhal's .NET wrapper. (SmugMug.NET) but I have to make multiple calls to get the albums, then the images within an album, then randomly select one of the images from that list.

    I'd like to have an api call like:

    smugmug.images.getRandom

    Arguments:* String SessionID
    • int AlbumID optional
    • Boolean Heavy optional
    • String Password optional
    • String SitePassword optional
    This could return a random image from all albums (or a selected albumID). This would be a lot less bandwith heavy than the multiple calls I am making now.

    Any thoughts?

    Thanks
    Paige Watson
  • darryldarryl Registered Users Posts: 997 Major grins
    edited January 31, 2008
    paigew wrote:
    I am currently doing this in C# for a DotNetNuke module I'm creating. I am using Evan Leventhal's .NET wrapper. (SmugMug.NET) but I have to make multiple calls to get the albums, then the images within an album, then randomly select one of the images from that list.

    Couldn't you avoid those last two steps (and avoid at least one heavy call) by just randomly selecting a gallery and then pointing the random.mg script at that gallery?

    --Darryl
  • paigewpaigew Registered Users Posts: 2 Beginner grinner
    edited January 31, 2008
    darryl wrote:
    Couldn't you avoid those last two steps (and avoid at least one heavy call) by just randomly selecting a gallery and then pointing the random.mg script at that gallery?

    --Darryl

    Yes, but I don't get the picture info (like name, description, date taken, etc). My first version has gets a users albums, then randomly selects an album and uses the random url. This is nice, but doesn't allow all the data to come with it.
Sign In or Register to comment.