Display random images from Gallery2 on a website

AlyxTakla

Joined: 2008-02-19
Posts: 1
Posted: Tue, 2008-02-19 09:56

Hello,

Are there any codes available or is it at all possible to display random images from Gallery2 defined by keywords on another part of my website?

For example, I have an article and I would like random photos from the gallery to display on this article defined by keywords on the photos, so if the article was about Australia, photos tagged with the keyword 'Australia' would randomly rotate where the script was placed in the article (I hope this makes sense!)

Regards,
Alyx

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2008-02-19 14:42

You can use the imageblock module and specify a specific album to select from.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
cascoly

Joined: 2008-02-20
Posts: 21
Posted: Thu, 2008-03-06 22:11

i searched the doc, and it says you need an external imageblock, but i couldnt find any more info on how to actually do this -- i want to do something similar - display random images from a particular album on a webpage

any refs?

http://pix-now.com/main.php

steve

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2008-03-06 22:39

install the imageblock module:
http://codex.gallery2.org/Gallery2:Modules:imageblock
the admin page of this module has directions for adding a external imageblock on a webpage.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
sork

Joined: 2008-03-16
Posts: 3
Posted: Sun, 2008-03-16 15:06

Is there a way to do this if it is not a php-page, but a html-page?
I know it is easy to change the page to php, but it is not my own page, and the user is not familiar with code.
The site is generated from a program (iweb) which has the ability to include a piece of html-code, like the code you can copy on youtube or flickr.

Is there a way to convert the rss-feed into html?
What I want is a thumbnail with a random picture from the gallery.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2008-03-16 16:11
 
cascoly

Joined: 2008-02-20
Posts: 21
Posted: Sun, 2008-03-16 19:58

does the link for random images have to be a website that supports php? the admin for imageblock shows this:

<?php @readfile('http://pix-now.com/main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=title'); ?>

i can extract the url and alone it works fine, but when i try to embed it in a webpage, it doesnt find the picture. i can display normal links just fine [eg, the image at the top of http://cascoly.com/maps.asp - i want to have that page display a random picture from the gallery, not this hard coded one.

steve

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2008-03-16 20:20

The image block uses php this page: maps.asp, uses active server pages, not the same.
So try suprsidr suggestion.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
cascoly

Joined: 2008-02-20
Posts: 21
Posted: Sun, 2008-03-16 20:33

ok, thanks - i hadn't thought there'd be any problem including this on asp site, but now see there
s a difference between the direct link, and the random which needs to actually run a process. as might be obvious, php is new to me]

i did check out the slideshow, but it looked like overkill when i just wanted to display one random image each time someone accesses the page. i certainly dont want them to have to download dozens or hjundred thumbnails each time they move from page to page on my site. so, i'll look to see about setting up an ultramini slideshow of 1-3 images.

steve

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2008-03-16 20:41

You could try a iframe if you wish

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
sork

Joined: 2008-03-16
Posts: 3
Posted: Sun, 2008-03-16 22:57

To suprsidr:
Thank you very much! It looks nice and works great.

 
HaroldM
HaroldM's picture

Joined: 2008-01-05
Posts: 7
Posted: Fri, 2008-09-12 14:56

OK so I've got a random image displaying on my page but is there a way for it to show the description for each image? I see the only options are like title, heading, etc. but I was wondering how to display a description I entered for that image. I'm using this for a realty type site and it's displaying random pictures of houses for sale. For each image I enter in a description of like 2BR/2BA and want that displayed. Any way to do this? I thought maybe doing g2_show=summary would work but no luck. That just displays no text at all. I know I could just change the Title and I've done that for now but is there an easier way?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2008-09-12 20:55
Quote:
I thought maybe doing g2_show=summary would work but no luck. That just displays no text at all.

Do you have text in the sunmmary? Copy the description to the summary.

I guess you could edit the imageblock module code to display the description instead of the summary.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
HaroldM
HaroldM's picture

Joined: 2008-01-05
Posts: 7
Posted: Fri, 2008-09-12 20:57

I ended up putting the description in the Summary and that's working out for me just fine for now. I may look into editing the imageblock module if I have to go that route later on. Thanks for the help though.

 
lukedan

Joined: 2010-07-27
Posts: 52
Posted: Sat, 2010-08-14 19:58

Is this still working?
I tried with "g2_show=summary" but no results.

-My Gallery-
http://www.seibella.ro/poze

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2010-08-14 20:33
 
lukedan

Joined: 2010-07-27
Posts: 52
Posted: Sat, 2010-08-14 21:12

Are you sure ?
I'm not seeing summary for UpdatesAlbum.

-My Gallery-
http://www.seibella.ro/poze

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2010-08-14 21:32

edit line 505 instead of getTitle($item) use $item->getSummary()

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
lukedan

Joined: 2010-07-27
Posts: 52
Posted: Sun, 2010-08-15 09:18

Thanks but I need both: Title and summary
Can you help me in editing dynamic albums module? or imageblock module?
I can replace "data" or "owner"

-My Gallery-
http://www.seibella.ro/poze

 
lukedan

Joined: 2010-07-27
Posts: 52
Posted: Sun, 2010-08-15 09:56

+ mediablock is not working for updatesAlbum - I need only albums, not pictures inside albums

-My Gallery-
http://www.seibella.ro/poze

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2010-08-15 12:42
Quote:
Thanks but I need both: Title and summary

Well, wouldn't it make sense to leave the title and add $item->getSummary()?

Quote:
I need only albums, not pictures inside albums

imageblock does the same.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
lukedan

Joined: 2010-07-27
Posts: 52
Posted: Sun, 2010-08-15 14:15

I put:
<?php @readfile('http://www.seibella.ro/poze/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=11&useThumb=1&column=4');?>
on http://www.seibella.ro/test.html
Nothing happened
With
<?php @readfile('http://www.seibella.ro/poze/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.RandomAlbum&limit=11&useThumb=1&column=4');?>
everything is ok

http://www.seibella.ro/poze/main.php?g2_view=dynamicalbum.UpdatesAlbum
is ok

Any help?

-My Gallery-
http://www.seibella.ro/poze

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2010-08-15 14:27
 
lukedan

Joined: 2010-07-27
Posts: 52
Posted: Sun, 2010-08-15 14:56

I set data items only
Now it brigs me pictures inside last album. It looks you have same situation. I see 3 cats from your '4 Maria" album.
I need only albums like in: http://www.seibella.ro/poze/main.php?g2_view=dynamicalbum.UpdatesAlbum

-My Gallery-
http://www.seibella.ro/poze

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2010-08-15 15:05

I was just thinking about that, I filter albums because they are only a container which may not have a thumb - breaking the script.
On my site the user albums quite often get created and the user does not upload anything hence no thumb.

But you can remove the album check and return to "show albums only"
mediaBlock.php line ~272:

                if (!($childItem->entityType == "GalleryAlbumItem")) {
                    $display .= getDisplay($childItem);
                }

to:

                $display .= getDisplay($childItem);

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2010-08-15 15:10

or add a REQUEST variable instead to disable the check so you don't break other dynamic operations by mistake:

                if (isset($_REQUEST['allowAlbums']) || !($childItem->entityType == "GalleryAlbumItem")) {
                    $display .= getDisplay($childItem);
                }

then you would add allowAlbums=true to your url: http://www.seibella.ro/poze/mediaBlock.php?mode=dynamic&g2_view=dynamicalbum.UpdatesAlbum&limit=11&useThumb=1&column=4&allowAlbums=true
only when you need to.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
lukedan

Joined: 2010-07-27
Posts: 52
Posted: Sun, 2010-08-15 15:31

It works.
Thanks a lot.

-My Gallery-
http://www.seibella.ro/poze

 
lukedan

Joined: 2010-07-27
Posts: 52
Posted: Mon, 2010-08-16 14:59

Any ideea how to have Description intead of Summary?
I tried "getDescription()" but no results :)
Thanks

suprsidr wrote:
Quote:
Thanks but I need both: Title and summary

Well, wouldn't it make sense to leave the title and add $item->getSummary()?

Quote:
I need only albums, not pictures inside albums

imageblock does the same.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

-My Gallery-
http://www.seibella.ro/poze

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2010-08-16 15:07

$item->getDescription()

in my jQuery version, I use the description for the hover tip - pretty cool.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
lukedan

Joined: 2010-07-27
Posts: 52
Posted: Mon, 2010-08-23 12:31

Thanks suprsidr a lot.
You may see our result on http://www.seibella.ro/

-My Gallery-
http://www.seibella.ro/poze

 
lukedan

Joined: 2010-07-27
Posts: 52
Posted: Mon, 2010-08-30 18:30

Any chance to use friendlyurl for link?

-My Gallery-
http://www.seibella.ro/poze

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2010-08-30 20:04

in gallery admin -> rewrite, you can setup embedded gallery to rewrite the links in the root of your site same as /poze/

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
lukedan

Joined: 2010-07-27
Posts: 52
Posted: Tue, 2010-08-31 06:58

Gallery allready use friendly url.
MediaBlock use "http://www.seibella.ro/poze/main.php?g2_view=core.DownloadItem&g2_itemId=26917&g2_serialNumber=4&g2_GALLERYSID=TMP_SESSION_ID_DI_NOISSES_PMT"
instead of
http://www.seibella.ro/poze/Coafuri-ocazie-mireasa-schimbari-look/10-07-Machiaj-coafura-nunta/

-My Gallery-
http://www.seibella.ro/poze