PDA

View Full Version : Addon: Display latest thumbnail in external website


tinyblob
11-28-2005, 01:18 PM
Following a conversation with Raminia regarding problems people were having with his own addon, i knocked up a quick replacement.

I'm not familiar with the specific problems people were having, but if you had issues - try this addon.

The basic concept is as follows:

* You have another website, or blog, which you'd like to display your newest thumbnail on.
* You don't know how to use PHP, or the website is on an external server.

This addon allows you link to pixelpost as if it were an image file. The latest thumbnail will appear like magic!

for example:

<img src="http://yourwebsite/index.php?x=latestthumb" title="latest image" alt="latest image">

annoyingly i can't post an example thumbnail in the forum, vBulletin doesn't want to interpret the url as an image, despite the img tags.


Download v0.1 here (http://touchnothing.net/files/latestthumb.zip)

NOTES:

* I knocked this addon up really quickly, so it may be flawed.
* Raminia's addon had the facility to display images OR titles. This one doesn't do titles, it just displays the image directly.
* Unlike Raminia's addon, this one detects the file type and displays the correct header. I have no idea what filetypes Pixelpost supports, so this version only detects JPG and GIF.
* This addon forces the image to load inline, so even if you navigate to index.php?x=latestthumb the graphic will still load.


If anyone actually uses this addon let me know if you want features added to it, like loading more recent thumbnails.

d72
11-28-2005, 02:30 PM
tnx! this worked just fine on my blog's sidebar.
this Raminia-thing did not show anything on my blog, don't know what i did wrong, I guess I'm not the onlyone..

loading more thumbs is good idea and random-feature is useful too (e.g I'd like to show 2 new and 2 random thumbs on my page's sidebar)

I start to hack from your version and try my tiny php skills on it.:rolleyes:



d72.pri.ee (http://d72.pri.ee/)

raminia
11-28-2005, 02:33 PM
I was wondering if the php script can grab the image title from a <script src=somephp.php> tag and put it into the <img> coponent through a jscript code. I was just wondering.

tinyblob
11-28-2005, 02:56 PM
@d72:
what i will do in the next version is allow you to specify another variable in the img tag, which will select the "position" of the thumbnail you want to select.
for example, the first img tag will display the most recent thumbnail, the second img tag can display the second most recent... and so on.
in the next version i'll also implement a "random" image.

@raminia:
with that assumption you are going towards AJAX!
I am thinking about looking at some Pixelpost <--> AJAX code soon when i have run out of Addons to make ;)

GeoS
11-28-2005, 04:02 PM
Last thumb can be done in few ways:
1) when uploading new file we are making link (on Linux/Unix servers) or copy of the newest file.
2) grab RSS and get first appearance of image link.
3) ...

tinyblob
11-28-2005, 04:52 PM
3) ... this addon right here?

GeoS
11-28-2005, 06:21 PM
Yeap :)

raminia
11-28-2005, 08:59 PM
Horray!

wadeferd
11-29-2005, 09:26 PM
What about bringing the entire row into an external page ? Any ideas there ? Ramina already pointed me towards her wordpress plugin, but i use nucleus and they're not getting along. Any ideas ?

tinyblob
11-29-2005, 09:53 PM
i'll update it soon for that purpose!

wadeferd
11-29-2005, 10:14 PM
i'll update it soon for that purpose!

awsome.

John
11-30-2005, 08:07 AM
that's another great idea & add-on, tinyblob.
I needed it but I used RSS + Parser to get the same result ;)
[ and I get the title, description .. all the informations I need ]

tinyblob
11-30-2005, 09:24 AM
RSS + Parser is a far better solution, seeing as RSS exists to syndicate content :)
But the idea of this addon is to give the ability to people who either don't have coding skills, or are working in an environment where it's not feasible (plain HTML etc).

raminia
11-30-2005, 09:28 AM
please upload it into pixelpost.org/v1

Paul Wood
11-30-2005, 04:44 PM
Any idea on how something like this can be used in forum signatures? Most forums I belong to only allow a direct image link.

tinyblob
11-30-2005, 05:04 PM
Yeah, i gave that some thought.
I'll get back to you on it :)

Paul Wood
11-30-2005, 06:07 PM
Here's a tutorial someone might be able to adapt, if they're more adept at PHP than I am.

http://www.codedemons.net/tutorials/PHP/Dynamic-Forum-Signatures?p=1

Paul Wood
12-01-2005, 01:40 AM
I managed something like what we're talking about that will work for me for a while. I'd rather have the latest image -- this code picks a random image, and it doesn't care if it is a future image.

So please, someone who knows how to do this: build something like this to retrieve the latest thumbnail instead of random!

<?php
/*
Based on code by Perpetual Dreamer and Alland.
Modified by Paul Wood, who knows nothing about PHP.

Instructions:

Modify the $path variable to your thumbnails directory.

Then, just link to the script as a php file. Can be used in a site, such as <img src="filename.php">,
or a forum, using [ img ]http://yoursite.com/filename.php[ /img ]

*/

//directory here (relative to script)
$path = 'thumbnails';

$i = 0;
$imgDir = opendir ($path);
while ( $file = readdir( $imgDir ) )
{
//checks that file is an image
$file_type = strrchr( $file, "." );
$is_image = eregi( "jpg|gif",$file_type );

if ( $file != '.' && $file != '..' && $is_image )
{ $images[$i++] = $file; }
}
closedir ($imgDir);

srand( (double) microtime()*1000000 );
$image_name = $path . '/' . $images[rand( 0,sizeof( $images ) -1 )];
$imgSize = GetImageSize( $image_name );

//ends script if no images found
if ( $i == 0 )
die();

//Display the image
header('Content-Type: image/jpeg');
header('Content-transfer-encoding: binary');
$img = imagecreatefromjpeg($image_name);
imagejpeg($img);



?>

tinyblob
12-01-2005, 08:25 AM
I'll adjust mine to use the imagecreatefromjpeg() function after i've had my morning coffee.

steff
12-01-2005, 12:52 PM
I managed something like what we're talking about that will work for me for a while. I'd rather have the latest image -- this code picks a random image, and it doesn't care if it is a future image.

So please, someone who knows how to do this: build something like this to retrieve the latest thumbnail instead of random!


quote! I would appreciate too! :)

Paul Wood
12-01-2005, 01:29 PM
I'm learning. This works to display the latest image, but I'd appreciate someone familiar with PHP and MySQL take a look at it and see if I need to add anything for proper coding.

<?php
/*
Based on code by Perpetual Dreamer and Alland.
Modified by Paul Wood, who knows nothing about PHP.
Portions of this code from scripts by tinyblob and Raminia

Instructions:

Put this file in your pixelpost root dir and link to the script as a php file. Can be used in a site, such as <img src="filename.php">,
or a forum, using [ img ]http://yoursite.com/filename.php[ /img ]

*/
require("includes/pixelpost.php");

function start_mysql()
{
global $pixelpost_db_host, $pixelpost_db_user, $pixelpost_db_pass, $pixelpost_db_pixelpost;
mysql_connect($pixelpost_db_host, $pixelpost_db_user, $pixelpost_db_pass) || die("Error: ". mysql_error());
mysql_select_db($pixelpost_db_pixelpost) || die("Error: ". mysql_error());
}

function pullout($str)
{

$str = stripslashes($str);
$str = UTF8_decode($str);
return $str;
}

start_mysql();

// get current time
$datetime = date("Y-m-d H:i:s");
$cdate = $datetime; // for future posting


// Get Current Image.
$query = mysql_query("select image,headline,datetime,id from ".$pixelpost_db_prefix."pixelpost where datetime<='$cdate' order by datetime DESC limit 0,1");


$row = mysql_fetch_array($query);
if(!$row['image']) {
echo "Coming Soon (query fail)!";
//exit;
}
$image_name = $row['image'];
$image_title = pullout($row['headline']);
$image_id = $row['id'];
$image_datetime = $row['datetime'];

// filename
$image_name = 'thumbnails/thumb_'.$image_name;


$imgSize = GetImageSize( $image_name );


//Display the image
header('Content-Type: image/jpeg');
header('Content-transfer-encoding: binary');
$img = imagecreatefromjpeg($image_name);
imagejpeg($img);



?>

tinyblob
12-01-2005, 01:58 PM
Paul, that's wayyy over complicated. Good job though!

My latest image:
http://www.touchnothing.net/blog/thumb.php

This isn't actually an addon to pixelpost, it's a standalone file that you just drop in your pixelpost folder:

thumb.php (http://www.touchnothing.net/files/thumb.zip)

To link to your thumbnails, just do it with normal image tags, but instead of linking to a .jpg you'd be linking to this .php file. Bear in mind that this file has to be in your pixelpost directory to function.


I can update the addon version if anyone uses it, but this "external file" method will actually be faster.

Paul Wood
12-01-2005, 02:07 PM
Paul, that's wayyy over complicated. Good job though!


Thanks -- it was cobbled together from other scripts, since I don't really know what I'm doing.

I have the date function in there because I don't want to display my future images as my latest image thumbnail. I try to post 4 or 5 days in advance in case I get too busy or forget.

tinyblob
12-01-2005, 02:13 PM
okay :)

raminia
12-01-2005, 10:51 PM
I dont like this kind of signature.

I'm not really a fan of pictures in signature and I think Blinking should ban this. Dynamic ones are worst. In forum posts should have consistancy and these signatures will break that. sorry just a peronal opinion.

Paul Wood
12-01-2005, 11:03 PM
I disagree. I think consistency lies with the avatar, and this is an excellent way to encourage people to visit your blog.

However, I'm not one to encourage rebellion, so I'll remove this sig from this forum. I really wanted it for my local theatre forum, anyway.

tinyblob
12-01-2005, 11:07 PM
I'm not really a fan of pictures in signature and I think Blinking should ban this.
Harsh.

As a photographer i like being surrounded by photographs, both mine and other peoples. This is a forum for photobloggers, by photobloggers, about photoblogging software. Why don't photos have a place here?

At 2-5KB they don't exactly slow the forum down, and i don't see why they're any less consistent than having a couple of lines of hyperlinks or whatever in your sig.

I liked the idea because it let regular posters know when i've updated, not everyone uses RSS feeds. But i've removed it now.

Joe[y]
12-02-2005, 09:15 AM
meh - i have no problem at all with it! as long as people don't have 800px wide thumbs :P

though, would be cool if it could be used for forum avatars! my 80x80 thumbs would fit the bill just fine!

tinyblob
12-02-2005, 09:19 AM
Well you can enter an url for your avatar - try it!

Joe[y]
12-02-2005, 09:20 AM
Well you can enter an url for your avatar - try it!

when i get home.

raminia
12-02-2005, 07:28 PM
Harsh.

As a photographer i like being surrounded by photographs, both mine and other peoples. This is a forum for photobloggers, by photobloggers, about photoblogging software. Why don't photos have a place here?

At 2-5KB they don't exactly slow the forum down, and i don't see why they're any less consistent than having a couple of lines of hyperlinks or whatever in your sig.

I liked the idea because it let regular posters know when i've updated, not everyone uses RSS feeds. But i've removed it now.
sorry for being harsh. :)
I'm not the forum owner here and said that as a personal opinion not even at the position of a moderator. :rolleyes:

blinking8s
12-02-2005, 09:08 PM
forum signatures can be an artform...but they can also be the most annoying things in the world

my only guidelines are that they dont take up a CHUNK of space, break the forum templates, or make me go blind

i prefer things as simple as possible though, and odds are in the near future i will give this forum a total overhaul

unseen
12-03-2005, 06:45 PM
just testing this:
http://www.unseen.zeeder.com/pixelpost/thumb.php

EDIT: that is amazing. okay, now trying it with my avatar...
EDIT: hmm. won't work as an avatar, it says it's an invalid filetype...

tinyblob
12-03-2005, 07:18 PM
unseen, i'm making an addon for v1.5 that will create a copy the latest thumbnail to a specific place. so every time you upload a new image, that one gets updated too.
you'd be able to use that one, assuming vBulletin links to external avatars, rather than downloading them.

unseen
12-03-2005, 07:37 PM
oh awesome! thanks :]

Paul Wood
12-03-2005, 07:44 PM
tinyblob, that will be a great addon! Thanks!

I'm looking forward to 1.5

ravenswift
04-20-2006, 02:40 AM
I'm not sure what I'm doing wrong.

I downloaded the addon, unzipped it, uploaded the PHP file to my server, added the line of code into my Blogger blog's template, changed the details to direct to my photoblog.

All it's showing is the alt text. Am I missing something? Is there nothing I have to change in the PHP file before I uploaded it to my server? BAH! :confused:

Ubbe
05-01-2006, 03:27 PM
wow super post, it works perfectly fine on my site atleast, i would just like to here if there was some way you could also get the notes to the newest photo with? :P:D

HiImSeth
05-05-2006, 03:00 PM
Cool, I was going to use this to add my latest photo to my myspace page. However, it looks like they drop img tags that call php files. =\

I'm not much of a coding type so if anyone has ideas or something that I could use to get around that, that would be excellent.

parrimin
05-10-2006, 12:59 PM
Hi, sorry but i canīt use that thum.php
Ill explain, i have page.php in maindirectory, and thumb.php in maindirectory/pixelpost1-5rc1-2. If i go in browser directly to maindirectory/pixelpost1-5rc1-2/thumb.php i can see my thumb, but if i put in as a image into page.php, i canīt see it. The code in page.php is:
<img src="pixelpost1-5rc1-2/thumb.php">
I tried <img src="http://maindirectory/pixelpost1-5rc1-2/thumb.php"> too, but doesnīt work either.
Can somebody explain me like iīm a child, iīm a noob in php, and my english is not very well
Thaks;)

parrimin
05-10-2006, 03:33 PM
Iīve had a syntax error, i was loading the images from an old page i was creating (I copied the template for begin) :D . Now can see the thumb perfectly! This works....

TommyBlue
05-16-2006, 10:27 PM
So this thumb.php file is great, but I'm noticing that it seems to recreate the jpg for the thumb, resulting in a huge image quality loss... I've got artifacts all over the external thumbnail, but the actual thumb from pixelpost is much better (85 quality). Is there no way around this? A way to save it with a higher quality setting? A way just to post the actual thumbnail image file that PP saves? I'd love to hear any options, thanks. =)
-Tommy

fruitystar
05-19-2006, 02:22 PM
Hi TinyBlob,

I installed the add-on (from your first post on this thread) and unfortunately the thumbnail wasn't displayed on my non-pixel post webpage. It only shows the Alt description. Someone else also mentioned they had this problem in this thread.

I unzipped the file and placed the add on into the addon directory. It shows that the addon has appeared in my admin area. Just the link on the external web page doesn't seem to get the thumbnail with: http://yourwebsite/index.php?x=latestthumb.

The link I am writing specifically for where i have pixelpost installed is this: http://mywebsite/myname/photos/index.php?x=latestthumb

ravenswift
05-20-2006, 09:38 PM
I've looked at page sources from other people's sites where this addon is actually working, and I still can't figure it out.

I've added this to my Blogger template:

<a href="http://www.karigignac.com/"><img src="http://www.karigignac.com/index.php?x=latestthumb" title="latest image" alt="latest image">
</a>

It still only shows the ALT text.

Here's a link to my site, where you can see that it's not working:
http://karigignac.blogspot.com

PLEASE HELP!! :eek:

Glovebox
05-24-2006, 09:03 AM
Hi Fruitystar and Ravenswift,

What's with the "x=latestthumb" thing? My external link looks like this:

<a href="http://www.doodleblog.co.uk" target="_blank"><img src="http://www.doodleblog.co.uk/thumb.php" border="0" alt="This is the latest image from Doodleblog.co.uk" /></a>

Oh, hold on, you seem to have got it working...

Cheers,
Simon

Doodleblog (http://www.doodleblog.co.uk) - simple but subtly addictive...

ravenswift
05-24-2006, 03:12 PM
But it's not the PixelPost addon anymore. It's a little javascript thingy that my friend made up. Apparently the content type on the addon was wrong and we couldn't figure out how to change it. So we scrapped it and did it our own way.

stolen
06-22-2006, 07:02 AM
....You have another website, or blog, which you'd like to display your newest thumbnail on.

This addon allows you link to pixelpost as if it were an image file. The latest thumbnail will appear like magic!

<img src="http://yourwebsite/index.php?x=latestthumb" title="latest image" alt="latest image">

Download v0.1 here (http://touchnothing.net/files/latestthumb.zip)....



This is exactly what I am looking for... My wordpress is installed on a different domain to my photos (sig).

Unfortunately the above d/l link no longer works. Any hints?

**EDIT**

I have installed and run the script that Paul wrote about here:
http://forum.pixelpost.org/showpost.php?p=19324&postcount=21

However, it seems to register my second most recent thumb and not my most recent thumb. I think it may be to do with the fact all date and times set on my server will be one day behind my time (US vs AUS time) Any ideas how to fix that?