View Full Version : random thumbs...?
-okapi-
02-14-2005, 11:00 AM
just a request...
would it be a hard thing to write an addon for displaying one or more clickable random thumbnails? i think, for a photoblog, especially when it has become bigger, this is a very nice feature, because it invites visitors also to take a look at older images...
what i really love about pixelpost is it's modular structure. that makes me think (sorry, i'm a php layman) that this could maybe be done as an addon...
what is your opinion about that?
Connie
02-14-2005, 02:41 PM
I don't think it would be too hard, but I don't know who has the time to do this :oops:
well, as the number of thumbnails is known from the database, it would be not too difficult
- to get this value from the database
- to find a random value between 1 and this value
- to create a link to the thumbnail with this random value
it's just a question of time and testing..
-okapi-
02-14-2005, 03:43 PM
thank's for your answer, connie,
yes, i know, it takes time and effort to develop such goodies...
hmm...
all i can do now
is hope,
that somebody,
who has the skills to do it
agrees with me,
that this would be a very nice feature
and
has some time left to...
;)
raminia
02-14-2005, 05:48 PM
It is done!
I uploaded it on the addon section.
http://www.pixelpost.org/index.php?x=downloads&details=40
Random Thumbs (random_thumb.php - version 0.1)
This addon will enables the tag <IMAGE_THUMBNAIL_RANDOM_ROW> which shows random thumbnails from the database. This tag could be used similar to the original date-oriented thumbnail tag <IMAGE_THUMBNAIL_ROW>
Usage:
Place <IMAGE_THUMBNAIL_RANDOM_ROW> in your image_template.html where you want the random thumbnails to appear.
raminia
02-14-2005, 06:13 PM
I don't think it would be too hard, but I don't know who has the time to do this :oops:
well, as the number of thumbnails is known from the database, it would be not too difficult
- to get this value from the database
- to find a random value between 1 and this value
- to create a link to the thumbnail with this random value
it's just a question of time and testing..
I've done it this way
$thumbs_ahead = mysql_query("select DISTINCT id,headline,image from ".$pixelpost_db_prefix."pixelpost where id!=".$image_id." order by rand() asc limit 0,$thmb_numb");
:D
-okapi-
02-14-2005, 07:26 PM
thank you so much, raminia!
perfectly done, and that was really lightning fast...!
amazing work!
i really love this feature.
by the way, i'm wondering what makes a call to a function (hopefully i'm right, maybe i should just say "tags") like <IMAGE_THUMBNAIL_RANDOM_ROW> work only with image_template.html but not with about_template.html for example, while others, like <SITE_RSS_LINK> or <SITE_CALENDAR> work with any page...
again, thanks a lot!
Connie
02-14-2005, 07:39 PM
@Ramina,
you are so fast! I just made a similar addon, to train my understanding of php....
but your's is there and that is ok!
@okapi,
this phenomen is becaused some of these tags are generated by the script later than the part for the special template , the script actually does not generate all tags first and then handles the different requests...
:roll:
-okapi-
02-14-2005, 08:06 PM
i see...!
as far as i can see, at least ;)
thanks connie!
i wish i had the time to learn more about php, but then, i think, i wouldn't see no daylight any more... ;)
greentraveler
02-14-2005, 08:09 PM
I've been wondering if there's a way to display a random fullsize photo for a while but never threw the request out.
But now it looks like it might be possible...is there a way to alter this code to make this possible?
Thanks in advance! :)
raminia
02-14-2005, 08:14 PM
Thanks okapi! Thanks Connie!
as okapi asked I've changed it right away to show 5 new thumbnails withought the displayed image as a thumb.
I put the old code here for every one who might be interested in the first version
<?php
/*
Requires Pixelpost version 1.3
Random Thumb Addon version 0.1
Written by: Ramin Mehran
Contact: raminia@yahoo.com
Pixelpost www: http://www.pixelpunk.se/software/
License: http://www.gnu.org/copyleft/gpl.html
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
$addon_name = "Random Thumbs";
$addon_description = "This addon will enables the tag &lt;IMAGE_THUMBNAIL_RANDOM_ROW&gt;
which shows random thumbnails from the database. This tag could be used similar to the original
date-oriented thumbnail tag &lt;IMAGE_THUMBNAIL_ROW&gt;<br> <br>Usage:<br>Place
&lt;IMAGE_THUMBNAIL_RANDOM_ROW&gt; in your image_template.html where you want the
random thumbnails to appear.";
$addon_version = "0.1";
if(!isset($image_id)) {
// then we're showing the page from the admin section and don't bother doing anyhing.
} else {
// Get the number of thumbnails shown at once from the admin config
$cfgquery = mysql_query("select * from ".$pixelpost_db_prefix."config");
$cfgrow = mysql_fetch_array($cfgquery);
//---------------------------
$thmb_numb = $cfgrow['thumbnumber'] - 1;
// Code taken from index.php to get the thumbs ahead and behind
if(function_exists(gd_info)) {
$gd_info = gd_info();
if($gd_info != "") { // check that gd is here before this
$thumbs_ahead = mysql_query("select DISTINCT id,headline,image from ".$pixelpost_db_prefix."pixelpost where id!=".$image_id." order by rand() asc limit 0,$thmb_numb");
while(list($id,$headline,$image) = mysql_fetch_row($thumbs_ahead)) {
list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name");
$rnd_thumbs .= "<a href='$PHP_SELF?showimage=$id'><img src='thumbnails/thumb_$image' alt='$headline' title='$headline' class='thumbnails' width='$local_width' height='$local_height' /></a>";
$totalthumbcounter++;
}
$thumbnail_row = "<a href='$PHP_SELF?showimage=$image_id'><img src='thumbnails/thumb_$image_name' alt='$image_title' title='$image_title' class='current_thumbnail' width='$local_width' height='$local_height' /></a>$rnd_thumbs";
$tpl = ereg_replace("<IMAGE_THUMBNAIL_RANDOM_ROW>",$thumbnail_row,$tpl);
} // gd_info()
} // func exist
}
?>
raminia
02-14-2005, 08:32 PM
I've been wondering if there's a way to display a random fullsize photo for a while but never threw the request out.
But now it looks like it might be possible...is there a way to alter this code to make this possible?
Thanks in advance! :)
random image is so easy! It is done! I'll post it in minutes
greentraveler
02-14-2005, 08:34 PM
WOW...thank you very much!
-okapi-
02-14-2005, 08:45 PM
exciting things are happening here!
raminia
02-14-2005, 08:47 PM
welcome;)
I post it in the addon section. Also I opened a new thread with "Random Image Link" in the title for who search for that specific feature.
raminia
02-14-2005, 08:54 PM
: ))
reading my writings in the description and these threads make me laugh ... I made many grammatical mistakes. That's because I'm lacking sleep and people make many mistakes in their symbolic level of concious when they are sleepy! oh that's a fact and I'm expericing it. It's about 2 am here...
raminia
02-14-2005, 09:04 PM
... I've changed it right away to show 5 new thumbnails
Oh I've reported it wrongly. It's not just fixed 5... it's as much as you mention in your amdin/option tab and mine is 5.
-okapi-
02-14-2005, 09:09 PM
you definitely need some sleep ;)
(edited: sorry, this was a crossposting, i meant it as a joke, not referring to your above post!)
so please ignore the following ;)
i have tried the random image link on my local server environment: but it only seems to work with a root install of pixelpost. the script seems to ignore the folder where pixelpost is installed in. so the output link doesn't work...
raminia
02-14-2005, 09:19 PM
oh yes!!
the addon is ok. the usage is not.
use this new one and it should be ok.
<a href='$PHP_SELF?showimage=<IMAGE_RANDOM>' > Random photo </a>
...I'll go to seeeelp!
-okapi-
02-14-2005, 09:33 PM
i apologize!
the first one works nicely, but only with image_template.html. i had tried it with other template files.
good night and thanks a lot!
usafdcc
02-15-2005, 01:57 AM
Is there a way to post this on another page like an about page, links page and not just the image_template page
raminia
02-15-2005, 05:30 AM
humm... There is some way. I'll try them.
-okapi-
02-15-2005, 05:53 AM
good morning, raminia!
:)
for me this is a basic question...
connie has tried to explain it to me, but -
testing php galleries i have always asked myself why code couldn't be written in way to get elements (calls of functions, tags...) that can be used with every template page. then, we would be free to build the site entirely individually, like with building blocks. we could have thumbnails, images, everything, on every page we want...
maybe this is a silly question...
but i'm curious.
raminia
02-15-2005, 06:22 AM
I've made changes to the addon and its now on version 0.3 !
Update: this tag is now availabe on all page of pixelpost photoblog.
raminia
02-15-2005, 06:29 AM
good morning, raminia!
:)
for me this is a basic question...
connie has tried to explain it to me, but -
testing php galleries i have always asked myself why code couldn't be written in way to get elements (calls of functions, tags...) that can be used with every template page. then, we would be free to build the site entirely individually, like with building blocks. we could have thumbnails, images, everything, on every page we want...
maybe this is a silly question...
but i'm curious.
Good morning:)
That's not silly question but what are you suggesting is a scripting language for photoblog! There is some sort of thing but limited on localservers. If you are familiar with Blogger.com you could see it behave in a similar manner. It has certain tags available for all tasks that a blogger needs and in the publishing section replaces all these tags with corresponding content in a static HTML code.
you can do such thing in your website but u need to connect to database and grab the tags. If you see my addon for displaying thumbnail on other pages of the website you could see a primary attempt to do it there. The exception is I did not make special tags (e.g. <latest_thumb> ).
raminia
02-15-2005, 06:31 AM
that's the addon I mentioned in the last reply for "Latest Thumbnail in other pages of the website "
http://www.pixelpost.org/index.php?x=downloads&details=38
Anonymous
02-15-2005, 08:54 AM
thank you very much for your work, raminia!
i'm looking forward to see the updated code in action in the evening...
have a nice day!
-okapi-
02-15-2005, 09:09 AM
thank you very much for your work, raminia!
i'm looking forward to see the updated code in action in the evening...
have a nice day!
sorry, i haven't been logged in!
raminia
02-15-2005, 09:45 AM
welcome.;)
to see it in action see my about page. I made it today al last!
http://pblog.raminia.com/index.php?x=about
raminia
02-15-2005, 10:29 AM
UPDATE: version 0.3.1 bug killed!
- The problem of not mentioning the width an height of the thumb in the image tag is solved. Tested and OK on Firefox and IE6.
This bug was the reason of not showing thumbs in IE6 on pager except the main page.
I'm done here!
BandonRandon
01-12-2008, 10:45 AM
How would i make this display only 1 image? Thanks
BandonRandon
01-14-2008, 03:39 AM
well i got it to work, as i am new to pixle post i didn't see the number of thumb rows in the admin page so i did it the hard way and modified the limit of the database to "1" but i acually ended up just copying random_thumb and renaming it to create a file that will in the php let you set the number and changed the tag from <THUMB_IMAGE_RANDOM_ROW> to THUMB_IMAGE_RANDOM> I figured this will allow me to have the flexibilty to see how many to display in the future.
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.