Jump to content


Display Random Image


31 replies to this topic

#1 rinty

    Etomite Forum Fan

  • Member
  • Pip
  • 87 posts

Posted 20 April 2006 - 02:00 PM

This is sort of a cross between EtoThumb and Etogal I suppose. I'd like to display a random image from one (or more) galleries on a page, larger than the thumbnail but smaller than the full size image. Ideally, it would also be clickable to go to that gallery (I modified style 0 in EtoThumb to allow that).

The end result would look like the mockup I've done on my homepage here. On that page, I've linked directly to the full size gallery image, but it has a size setting of 75%.

Would this be easy to do?

#2 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 20 April 2006 - 02:50 PM

rinty, on Apr 20 2006, 03:00 PM, said:

This is sort of a cross between EtoThumb and Etogal I suppose. I'd like to display a random image from one (or more) galleries on a page, larger than the thumbnail but smaller than the full size image. Ideally, it would also be clickable to go to that gallery (I modified style 0 in EtoThumb to allow that).

The end result would look like the mockup I've done on my homepage here. On that page, I've linked directly to the full size gallery image, but it has a size setting of 75%.

Would this be easy to do?
If you don't mind users actually loading the large image, and then the browser displaying the image at a diferent size, then its easy to do. Adding storage for an intermediate size image (or building an intermediate size image on the server on request for download) is a lot more work.

There was originally going to be an EtoGalImage to go with EtoGalThumbs, so that users could build their own gallery pages, but this would have meant a lot of duplication in the code used, including duplicating all the database code, so i gave up on it. (I've only written code I want, in general, because there hasn't been much in the way of requests for extra features. Now that I've got my gallery display snippet working correctly (eg Efikim floral gallery) I'll be tidying up that code (and removing the bit for sales) and releasing it too.)

If its going to be useful for others (ie you), I'll do an EtoGalImages - in your case EGThumbs won't be there so there won't be any duplication of code. Its easy for me to do (in principle) but I've got to get some images cleaned up, colour adjusted, cropped and printed by this evening so might not have time to do it today.

#3 rinty

    Etomite Forum Fan

  • Member
  • Pip
  • 87 posts

Posted 20 April 2006 - 03:11 PM

Well given download speed is not really much of an issue any more, and my site is not going to have massive bandwidth use, resizing the full image is okay for me but I suppose having an intermediate sized image on the server is the correct way to go :)

I do have EGThumb on my site (I wrongly called it EtoThumb on my first post, have a look at the One Less Child page on my site link above), if that makes a difference to your plans.

I suppose the random image idea would also be nice for EGThumb as well at times.

Edited by rinty, 20 April 2006 - 03:12 PM.


#4 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 20 April 2006 - 03:42 PM

Its OK, I'd interpreted EtoThumb as being EtoGalThumbs.

I don't see there being much of a gain bandwidth-wise from saving an intermediate sized image, so I'm no going to spend time on it , at least initally. Each user will only download the file once (then it goes into their cache), so you only save the overhead on not having a slightly smaller file on one access - and if they then go on to look at the larger image, then they download the full size one anyway, losing more than you gained the first time round.

rinty, on Apr 20 2006, 04:11 PM, said:

I suppose the random image idea would also be nice for EGThumb as well at times.
What do you mean? It already does give thumbs out in a random order if you don't specify an order (or at least, its supposed to), so if you specified you only wanted one thumb you'd get a random one.
After that, you can do what you want by writing your own styles. Part of the reason for it being designed the way it is is to make it easy to change the display even if you don't know PHP well. (I had hoped others might share styles too, but that hasn't happened.) If there's something specific you wanted to do, and can't see how to, let me know and I'll try.

The next version of EGThumbs will add some new features too.

#5 rinty

    Etomite Forum Fan

  • Member
  • Pip
  • 87 posts

Posted 20 April 2006 - 03:54 PM

mikef, on Apr 20 2006, 05:42 PM, said:

It already does give thumbs out in a random order if you don't specify an order (or at least, its supposed to), so if you specified you only wanted one thumb you'd get a random one.
Ahh! I'd missed that one :blush:

You may safely ignore that comment from me then ;)

#6 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 21 April 2006 - 02:02 PM

Attached is a 'quick fix' EtoGalImage to allow you to use the large images as a base for display, and works in exactly the same way as EtoGalThumb - let me know if this allows you to do what you want.

Its a temporary fix only, because I've decided to change the next version of EtoGalThumb to allow the use of either the thumbnail or the full size image for display (based on a snippet parameter).

I've put two styles in the snippet as examples, and put together a page at http://www.efikim.co.uk/EtoGalImage.shtml to demonstrate, though they don't look that good on my site because my full size images are relatively small, and so are being enlarged - should work better with larger images that are being shrunk!


EDIT
note that the new beta version of EtoGalThumb should render this snippet unnecessary, and offer more flexibility. EtoGalImage has now been removed as a result.

Edited by mikef, 02 May 2006 - 12:16 PM.


#7 rinty

    Etomite Forum Fan

  • Member
  • Pip
  • 87 posts

Posted 24 April 2006 - 02:50 PM

mikef, on Apr 21 2006, 04:02 PM, said:

Attached is a 'quick fix' EtoGalImage to allow you to use the large images as a base for display, and works in exactly the same way as EtoGalThumb - let me know if this allows you to do what you want.

Its a temporary fix only, because I've decided to change the next version of EtoGalThumb to allow the use of either the thumbnail or the full size image for display (based on a snippet parameter).

I've put two styles in the snippet as examples, and put together a page at http://www.efikim.co.uk/EtoGalImage.shtml to demonstrate, though they don't look that good on my site because my full size images are relatively small, and so are being enlarged - should work better with larger images that are being shrunk!
Yep - this looks just like my mock up :)
I've dropped the snippet in on my homepage (linked above) and created this style in the snippet:
// style=0 - a very basic banner
$styleStrings[0]['header']=0;
$styleStrings[0]['tail']=0;
$styleStrings[0]['image']=<<<IMG
<p align="center">><a href='[~%%gal%%~]'><img src='%%file%%' title='%%title%%' alt='%%sdesc%%' width=\"75%\" height=\"75%\"/></a></p><p align="center">%%title%%</p>
IMG;
I haven't set up a css style yet because it's only a temporary snippet so I just crudely set up a layout style in html (and called it 0 so I didn't have to call it - how lazy is that :D

What would be nice is if you could pull the gallery page title in as well so if you specified multiple galleries, you could also have a header. If you look at my homepage you'll see what I mean.

It would also be nice if rather than using a % on the size you could define a maximum display size. As it stands now, you sometimes get vary large portrait images and much smaller landscape on my page. It's obvious why, but it would have more consistancy if you could define a maximum size like EtoGal does on upload.

Edited by rinty, 24 April 2006 - 02:55 PM.


#8 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 24 April 2006 - 08:56 PM

rinty, on Apr 24 2006, 03:50 PM, said:

...

What would be nice is if you could pull the gallery page title in as well so if you specified multiple galleries, you could also have a header. If you look at my homepage you'll see what I mean.

It would also be nice if rather than using a % on the size you could define a maximum display size. As it stands now, you sometimes get vary large portrait images and much smaller landscape on my page. It's obvious why, but it would have more consistancy if you could define a maximum size like EtoGal does on upload.

I'll think about adding in the gallery page title to the replaceable parameters - though the code for the next version already includes longtitle and description as well as the alias. Do you really want the title rather than longtitle?

You could try specifying the pixel width/height in the style rather than a percentage, but I suspect some or all browsers would distort the image to fit the pixel dimensions. I'll think about adding a 'resize' parameter to the next version, but it breaks the principle of simple text substitutions into the style, and needs conditional handling to decide whether to specifiy a resized height or width.

PS - checking the code here, you already have the page longtitle and description available (%%ptitle%% and %%pdesc%%); example of use in style2 in etogalthumb, and shown on http://www.lowermosswood.org.uk/72.html .

Edited by mikef, 24 April 2006 - 09:34 PM.


#9 rinty

    Etomite Forum Fan

  • Member
  • Pip
  • 87 posts

Posted 24 April 2006 - 09:49 PM

mikef, on Apr 24 2006, 10:56 PM, said:

I'll think about adding in the gallery page title to the replaceable parameters - though the code for the next version already includes longtitle and description as well as the alias. Do you really want the title rather than longtitle?

You could try specifying the pixel width/height in the style rather than a percentage, but I suspect some or all browsers would distort the image to fit the pixel dimensions. I'll think about adding a 'resize' parameter to the next version, but it breaks the principle of simple text substitutions into the style, and needs conditional handling to decide whether to specifiy a resized height or width.

PS - checking the code here, you already have the page longtitle and description available (%%ptitle%% and %%pdesc%%); example of use in style2 in etogalthumb, and shown on http://www.lowermosswood.org.uk/72.html .
%%ptitle%% is returning nothing for me with this code
// style=0 - a very basic banner
$styleStrings[0]['header']=0;
$styleStrings[0]['tail']=0;
$styleStrings[0]['image']=<<<IMG
<h4 align="center">- %%ptitle%% -</h4><p align="center"><a href='[~%%gal%%~]'><img src='%%file%%' title='%%title%%' alt='%%sdesc%%' width=\"75%\" height=\"75%\"/></a></p><p align="center">%%title%%</p>
IMG;
If you look on my homepage, all you get displayed is the - - bit. Have I got that wrong?

#10 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 24 April 2006 - 10:05 PM

rinty, on Apr 24 2006, 10:49 PM, said:

%%ptitle%% is returning nothing for me with this code
// style=0 - a very basic banner
$styleStrings[0]['header']=0;
$styleStrings[0]['tail']=0;
$styleStrings[0]['image']=<<<IMG
<h4 align="center">- %%ptitle%% -</h4><p align="center"><a href='[~%%gal%%~]'><img src='%%file%%' title='%%title%%' alt='%%sdesc%%' width=\"75%\" height=\"75%\"/></a></p><p align="center">%%title%%</p>
IMG;
If you look on my homepage, all you get displayed is the - - bit. Have I got that wrong?
Sorry!
the snippet doesn't assume that the gallery id is the target page (because it isn't, on my sites!).
if you set the link parameter to the same value as gal, then the internal page based parameters (pdesc and ptitle) get set to the description and long title to those of the page that link is set to.

This snippet needs better documentation too, sometime! I didn't feel tpushed to do so, as no-one said they were using it, and no-one followed the request to share their styles.

#11 rinty

    Etomite Forum Fan

  • Member
  • Pip
  • 87 posts

Posted 25 April 2006 - 08:30 PM

mikef, on Apr 25 2006, 12:05 AM, said:

Sorry!
the snippet doesn't assume that the gallery id is the target page (because it isn't, on my sites!).
if you set the link parameter to the same value as gal, then the internal page based parameters (pdesc and ptitle) get set to the description and long title to those of the page that link is set to.

This snippet needs better documentation too, sometime! I didn't feel tpushed to do so, as no-one said they were using it, and no-one followed the request to share their styles.
Of course. I'd forgotten that I'd cheated by defining the href as %%gal%% rather than using %%link%%. It works fine now.

I did this because it seemed a waste of time to call the gallery and then have to call the link to the same gallery as a seperate variable. If you define multiple galleries for the random display, how does the the link variable tally up then?

Edited by rinty, 25 April 2006 - 08:31 PM.


#12 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 26 April 2006 - 08:50 AM

rinty, on Apr 25 2006, 09:30 PM, said:

If you define multiple galleries for the random display, how does the the link variable tally up then?

It doesn't. EGThumb and EGimage assume that each call of the snippet relates to a single target page. They don't assume that there is a one gallery per page mapping. My Galleries page calls the EGthumb snippet once for each page (which at present represents one gallery per page, but wouldn't if I wanted to split the landscape gallery by county.

Edited by mikef, 26 April 2006 - 09:08 AM.


#13 rinty

    Etomite Forum Fan

  • Member
  • Pip
  • 87 posts

Posted 26 April 2006 - 11:19 AM

mikef, on Apr 26 2006, 10:50 AM, said:

It doesn't. EGThumb and EGimage assume that each call of the snippet relates to a single target page. They don't assume that there is a one gallery per page mapping. My Galleries page calls the EGthumb snippet once for each page (which at present represents one gallery per page, but wouldn't if I wanted to split the landscape gallery by county.
Shame that. I'd hoped to be able to have my random image coming from any of the galleries and still have the title of the gallery above the image. Still, it's not the end of the world.

Thanks Mike

#14 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 26 April 2006 - 11:24 AM

rinty, on Apr 26 2006, 12:19 PM, said:

Shame that. I'd hoped to be able to have my random image coming from any of the galleries and still have the title of the gallery above the image. Still, it's not the end of the world.

Thanks Mike
I'll think about adding it for the next release, but I think it would have to assume that the gallery number was the page reference.

#15 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 29 April 2006 - 04:27 PM

EtoGalImage is now superceded by the new beta version of etoGalTumb available from the download area. This also adds support for the gallery longtitle (%%gtitle%%) in the image style string.
The EtoGalImage attachment previously in this thread has been removed.

Edited by mikef, 02 May 2006 - 12:18 PM.


#16 rinty

    Etomite Forum Fan

  • Member
  • Pip
  • 87 posts

Posted 02 May 2006 - 10:31 AM

mikef, on Apr 29 2006, 06:27 PM, said:

EtoGalImage is now superceded by the new beta version of etoGalTumb available from the download area. This also adds support for the gallery longtitle (%%gtitle%%) in the image style string.

I've left EtoGalImage attachment in this thread for now, in case the EtoGalThumb beta proves problematic, but the latter is recommended.
Great, thanks Mike. It's in and working :)

#17 rinty

    Etomite Forum Fan

  • Member
  • Pip
  • 87 posts

Posted 02 May 2006 - 10:49 AM

One more question Mike. I can't get the multiple galleries working.

[[EtoGalThumb?gal=23,27&fullsize=1&style=10]] generates an error because it's looking for a directory named 23,27.

Am I using that incorrectly?

#18 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 02 May 2006 - 11:12 AM

rinty, on May 2 2006, 11:49 AM, said:

Am I using that incorrectly?
No, its a bug added when I added the support for 'fullsize'.

Can you test the attached please?

Edit: attachment removed - the fix is included in the latest version availble from the Etogal downlioads section

Edited by mikef, 03 May 2006 - 03:00 PM.


#19 rinty

    Etomite Forum Fan

  • Member
  • Pip
  • 87 posts

Posted 03 May 2006 - 11:35 AM

mikef, on May 2 2006, 01:12 PM, said:

No, its a bug added when I added the support for 'fullsize'.

Can you test the attached please?
Yup - that's fine. Thanks Mike :)

#20 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 09 May 2006 - 06:27 PM

EtoGalThumb 1.1 beta 2 (available from the downloads area) now adds the 'resize' parameter you wanted too. It doesn't actually build a new image to download, but adjusts the width and height in the %%size%% string to scale the image to the size you request on display.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users