how to have a 'featured photo' on another page.

kappaluppa

Joined: 2002-11-16
Posts: 22
Posted: Tue, 2002-12-17 05:41

I want to be able to feature a photo and its caption on the index page of my site, as well as in the gallery.

Anybody do that yet? Any suggestions?

Thanks!

 
Kommercial
Kommercial's picture

Joined: 2002-08-19
Posts: 38
Posted: Thu, 2002-12-19 09:58

Hey,
You didnt mention wether or not you wanted to be able specify which picture that you wanted featured.
Currently there is only the 'Random photo block' feature which can be found by going into the user guide (link on left). There is also a top 10 photo feature in there.

If you mean you want it to automatically show the newest picture on your index page, then no there is no known features for that although plenty of people want it.
I still haven't been able to figure out how to do it.

 
kappaluppa

Joined: 2002-11-16
Posts: 22
Posted: Thu, 2002-12-19 11:20

Hi,

Yes I wanted one specific picture.

Well, i figured out a round about way how to do it. See http://www.andrewsamerica.com/index.php.

I made an album called Featured Photo. I put the picture I want featured in that album and renamed the picture to featured.jpg. then I took the link to that photo - view_photo - and copied the page and renamed it view_photo-1. then I included that new page into the index page of my site. I stripped out all the coding inthe page so that all that shows is the picture. Now all I have to do is upload a new featured photo with the name feature.jpg and delete the old one.

It's a pretty weird way around, but it worked.

I also did the same thing with a slide show at http://www.villageatcopper.com/opening.php. The slide show from a spefic album shows up on the main page and scrolls through the pictures.

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Sun, 2002-12-22 10:19

Hi guys. I liked the idea of a "featured photo", so I threw together a small PHP file.

It's featured-photo.php, and if you're interested, you can grab it <!-- BBCode Start --><A HREF="http://www.beckettmw.com/downloads/" TARGET="_blank">here</A><!-- BBCode End -->. You'll want to edit the $GALLERY_BASEDIR variable accordingly, and perhaps want to tweak the HTML output as well.

First, you put the file in your gallery/ directory, then add the following code to the bottom of the drop-down menu options in your view_album.php. This makes the option only available to the admin and to actual photos (no movies or sub-album highlights). There are no permission restrictions or hidden item restrictions because it's at the discretion of the admin which photo to choose.

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
if ($gallery->user->isAdmin() &amp;&amp; !strcmp($label, "Photo")) {
showChoice("Feature Photo", "featured-photo.php",
array("set" => 1,
"set_albumName" => $myAlbum->fields["name"],
"index" => $i));
}
</TD></TR></TABLE><!-- BBCode End -->

Now just put a <?php include("featured-gallery.php"); ?> where you want it and it's plug and play! This is how it looked when I threw it into my site:

<!-- BBCode Start --><IMG SRC="http://www.beckettmw.com/images/feature1.png"><!-- BBCode End -->

<!-- BBCode Start --><IMG SRC="http://www.beckettmw.com/images/feature2.png"><!-- BBCode End -->

Hopefully it'll be of some use to a couple people. This is a good starting base for putting more features together. How about adding featured photos to a queue? So you could have a new photo every week, say, but you could line a whole bunch up and let it run for months. Just some ideas. Or... featuring the most visited photo. (This segues into the "5 most recently visited images thread...).

If you try it out, let me know how it goes.
Happy holidays,
-Beckett (

)

 
Gaile

Joined: 2002-07-20
Posts: 1301
Posted: Mon, 2002-12-23 01:37

mmmm - nice one, Beckett!

I haven't been around much lately (getting ready for Christmas)! But in the bit of time I've had online I've been re-doing my website, including updating my Gallery and giving it a fresher look - I'm going to try incorporating this featured photo file into it, especially since I was never able to get the random thing to work.

Thank you for sharing this, I'll let you know when I have it up and running.

Merry Christmas from,

Gaile

 
pbyjp
pbyjp's picture

Joined: 2002-11-12
Posts: 260
Posted: Mon, 2002-12-23 06:55

Hey Beckett!
This is a great idea you had... in a way I can use it to display on my index the last updated picture very easily... that s smth I was trying to do re using the random block script but never managed to.
But with your script, I can do exactly the same really.
However, it seems that the files you put fup for dwld are messed up... can t read any of the .php files, even the .gz gives out some weird files... could you check that?
Also, is it possible to specify the size we want the featured photo to be displayed at?
Cheers.
excellent!
Paul

 
MiG

Joined: 2002-12-25
Posts: 1
Posted: Wed, 2002-12-25 07:03

Doesn't work.

I tried the downloads (all of them!) and they're all some sort of binary file.

Can you post the PHP script?

I think this is a great idea, and I'd love to be able to use it.

 
pbyjp
pbyjp's picture

Joined: 2002-11-12
Posts: 260
Posted: Fri, 2002-12-27 10:00

please Beckett,
can you repost your php files?
I mean... when you come back from holidays... :wink:
Paul

 
Agatka
Agatka's picture

Joined: 2002-10-19
Posts: 140
Posted: Fri, 2002-12-27 11:53

Hey, be patient. Patience is a virtue.

Let Beckett have some fun before he comes back to hard work :smile: helping oders.

Agatka

 
sdiddy

Joined: 2002-11-25
Posts: 9
Posted: Sat, 2002-12-28 19:29

:sad: no xmas surprise of beckett supplying the file!

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Thu, 2003-01-02 03:43

Hi guys. I'm still on holidays, and have very very limited access to a computer, and no SSH client, so my hands are tied as far as logging into my box to fix this. I'll re-upload the file just as soon as I get back, and will let you know. :sad:

Happy 2003,
-Beckett (

)

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Sun, 2003-01-05 22:56

Okay. I'm back at my computer and I believe it's fixed now. Let me know how you fare.

Cheers,
-Beckett (

)

 
dodofreak
dodofreak's picture

Joined: 2002-12-09
Posts: 75
Posted: Mon, 2003-01-06 01:46

Beckett, it works wonderfully!

Thanks for providing such a nice hack!

Maybe they can roll this into gallery 1.3.4.

Happy holidays!! :grin:

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Mon, 2003-01-06 02:57

Glad you like it. :smile:

Quote:
Maybe they can roll this into gallery 1.3.4.

As with the random block, I think this is best left as an "add-on", since the featured photo block gets placed outside of the actual gallery itself. If enough people get it working sans problèmes, then I'll see if someone can add it to the Gallery Add-ons page.

-Beckett (

)

 
BorgKing
BorgKing's picture

Joined: 2002-09-12
Posts: 314
Posted: Tue, 2003-01-07 19:36

Beckett, great script! I added it to one of my sites as well, but discovered that you were using the same URL for the photo and the album, in both cases linking to the photo. But even with my limited knowledge of PHP, I managed to correct this.

I didn't use the PHP include, since I want my main page to be HTML (everything else is PHP), so I included it as an iframe, which works seamlessly.

Thanks a lot for this great script, you can see it applied at <!-- BBCode Start --><A HREF="http://www.claessen.ca/" TARGET="_blank">Guido's Website</A><!-- BBCode End -->.

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Tue, 2003-01-07 20:02
Quote:
I added it to one of my sites as well, but discovered that you were using the same URL for the photo and the album, in both cases linking to the photo.

Good point! Okay, the image now points to the image and the album name points to the album. Thanks! :smile:

 
Gaile

Joined: 2002-07-20
Posts: 1301
Posted: Wed, 2003-01-08 05:10

I was having problems, but I think it was just my set up, and the fact that the index page I wanted it on is outside gallery. It kept linking oddly and the more I messed with it the worse it got. Then I dumped my changes, loaded it again and now it seems fine - so I don't know what I was doing (par for the course with me some days... :lol: )

I didn't want the text under it, and it links to the correct album, so all is good.

Thanks for this one, Beckett - very cool!

Regards,

Gaile

 
dodofreak
dodofreak's picture

Joined: 2002-12-09
Posts: 75
Posted: Thu, 2003-01-09 22:09

Hi all,

I'm not a PHP programmer by any stretch, but I liked Beckett's "Featured Photo" hack so much that I went ahead and translated it to a PostNuke block. It's really the random picture block translated so that it will display the "Featured Photo" as a PostNuke block instead of using an IFRAME. I did this because I just didn't like how the IFRAME looked within some PostNuke themes.

You can download it <!-- BBCode Start --><A HREF="http://www.storypath.com/pn/modules.php?op=modload&amp;name=UpDownload&amp;file=index&amp;req=viewdownload&amp;cid=2" TARGET="_blank">here.</A><!-- BBCode End -->

Enjoy and let me know if you find any bugs!

 
Carl_in_Florida
Carl_in_Florida's picture

Joined: 2003-01-07
Posts: 110
Posted: Thu, 2003-01-09 22:25

When I try to select a photo to be a feature I get this error:

Warning: fopen("/featured-photo.cache", "w") - Permission denied in /home/user/public_html/pix/platform/fs_unix.php on line 53
Error: Could not open cache file

Any Ideas?
Pix is the gallery directory

Thanks
:mad:

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Thu, 2003-01-09 22:32

Make sure you've set your $GALLERY_BASEDIR code correctly in the featured-photo.php page. The code needs to know where to find the Gallery code.

For instance, I think the default is set to:
$GALLERY_BASEDIR = "${DOCUMENT_ROOT}/gallery/";
which works if your gallery is located somewhere like:
http://www.mysite.com/gallery

If it's not, then you must change this (on line 24). If you're not sure what to change it to, please send us:

- The link to your gallery
- The path where your gallery directory is located

-Beckett (

)

 
oddjob

Joined: 2003-01-09
Posts: 18
Posted: Thu, 2003-01-09 22:33
Quote:
Now just put a <?php include("featured-gallery.php"); ?> where you want it and it's plug and play! This is how it looked when I threw it into my site:

If you try it out, let me know how it goes.
Happy holidays,
-Beckett (

)

Hi Beckett
I have tried your code and it works great but I want to put the featured photo on an index.php page which in not in the gallery directory. When I use the php include it does not work, I have even tried <?php include("gallery/featured-gallery.php"); ?> but that does not work. Can anybody tell me how to use a php include for a file in another directory?

Hope this makes sense
Oddjob (php novice ) :grin:

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Thu, 2003-01-09 22:52

Hi oddjob.

Try something like:

include("${DOCUMENT_ROOT}/gallery/featured-photo.php");
or
include("/the/full/path/to/my/gallery/featured-photo.php");

Then don't forget to edit the $GALLERY_BASEDIR in the code (see my comment above).

-Beckett (

)

 
fay

Joined: 2003-01-08
Posts: 16
Posted: Fri, 2003-01-10 10:16

great idea.. tested and running well! :grin:

 
oddjob

Joined: 2003-01-09
Posts: 18
Posted: Fri, 2003-01-10 10:46
Quote:
Hi oddjob.

Try something like:

include("${DOCUMENT_ROOT}/gallery/featured-photo.php");
or
include("/the/full/path/to/my/gallery/featured-photo.php");

Then don't forget to edit the $GALLERY_BASEDIR in the code (see my comment above).

-Beckett (

)

Hi Beckett
Thanks for taking the time to reply I have the $GALLERY_BASEDIR left as default because my gallery is in directory gallery and if I use include("${DOCUMENT_ROOT}/gallery/featured-photo.php"); that gets the photo onto the page but it has an error message preceding it :-
Warning: Cannot send session cache limiter - headers already sent (output started at /pub/home/********/htdocs/index.php:14) in /pub/home/********/htdocs/gallery/session.php on line 51

Any ideas
Oddjob (nearly there)

 
fay

Joined: 2003-01-08
Posts: 16
Posted: Fri, 2003-01-10 11:02

how to customize featured-photo.php to :

1) change the thumbnail to our own width and height? put width="xx" height="xx" to where? any sample?

thanks

 
Carl_in_Florida
Carl_in_Florida's picture

Joined: 2003-01-07
Posts: 110
Posted: Fri, 2003-01-10 15:42

Thanks for the advice. The code was wrong.
The problem I have now is this:
I am trying to do the featured photo on the home page thing.
I can type the url of the featured photo php (http://mydomain.com/pix/featured-photo.php) and i get it so i know it works. but when i use the <?php
include('/pix/featured-photo.php'); ?> code in my html homepage, I get nothing. I even tried <?php include('http://mydomain/pix/featured-photo.php'); ?> and i get nothing. Do I need to have some php stuff in the header or anything like that? I do not even know enough to be a novice at php. I dont even know what it stands for. I have anaged to alter enough gallery files to get gallery to look good in my site and now this is more a principle thing.
You know what I mean? My website is obvious so if anyone has advice I would appreciate it.
Carl :grin:

 
dodofreak
dodofreak's picture

Joined: 2002-12-09
Posts: 75
Posted: Fri, 2003-01-10 16:00
Quote:
Thanks for the advice. The code was wrong.
The problem I have now is this:
I am trying to do the featured photo on the home page thing.
I can type the url of the featured photo php (http://mydomain.com/pix/featured-photo.php) and i get it so i know it works. but when i use the <?php
include('/pix/featured-photo.php'); ?> code in my html homepage, I get nothing. I even tried <?php include('http://mydomain/pix/featured-photo.php'); ?> and i get nothing. Do I need to have some php stuff in the header or anything like that? I do not even know enough to be a novice at php. I dont even know what it stands for. I have anaged to alter enough gallery files to get gallery to look good in my site and now this is more a principle thing.
You know what I mean? My website is obvious so if anyone has advice I would appreciate it.
Carl :grin:

Carl,

Try including the full filesystem path.
Don't know if you running on Windows or a *Nix system.
./pix/featured-photo.php
/path/to/your/website/pix/featured-photo.php

 
Carl_in_Florida
Carl_in_Florida's picture

Joined: 2003-01-07
Posts: 110
Posted: Fri, 2003-01-10 16:44

I do not know if I am just not getting it or what. My host uses unix servers. Everything works fine (except the stuff that i messed up). Is it possible that i did something wrong in the featured-photo.php file? like i said if you go to http://carlandtracey.com/pix/featured-photo.php
it works. and on my home page http://carlandtracey.com you can look at the bottom of the page and see every variation i could think of for the link. Can you see what i am missing?

Does my index page HAVE to be renamed a index.php?

 
oddjob

Joined: 2003-01-09
Posts: 18
Posted: Fri, 2003-01-10 17:14

:grin: Well carlandtracey.com your mention of using the include in the form of :-
<?
include('http://www.ianhardy.net/gallery/featured-photo.php');
?>

has worked for me as you can see from <!-- BBCode Start --><A HREF="http://www.ianhardy.net" TARGET="_blank">home page</A><!-- BBCode End --> I had tried all manner of different include statements and I either got an error, no picture or a picture and an error. I only wish I could suggest something to help you.

 
Carl_in_Florida
Carl_in_Florida's picture

Joined: 2003-01-07
Posts: 110
Posted: Fri, 2003-01-10 17:34
Quote:
:grin: Well carlandtracey.com your mention of using the include in the form of :-
<?
include('http://www.ianhardy.net/gallery/featured-photo.php');
?>

has worked for me as you can see from <!-- BBCode Start --><A HREF="http://www.ianhardy.net" TARGET="_blank">home page</A><!-- BBCode End --> I had tried all manner of different include statements and I either got an error, no picture or a picture and an error. I only wish I could suggest something to help you.

I think the error is in my knowledge of php not in the code. I see your page is ../index.php i am trying index.html which is not working. index.php works. I guess that is the issue. Thanks for your time.
Is there any issue with older browsers opening a php file?

 
oddjob

Joined: 2003-01-09
Posts: 18
Posted: Fri, 2003-01-10 17:42

Hi Carl &amp; Tracey I have just had a look at your source code and (bear in mind this is coming from a complete amateur) you seem to have your include statments slightly different to mine. I have them in the form of
<?
include('http://www.ianhardy.net/gallery/featured-photo.php');
?>
whereas you have them as
<?php include("http://www.carlandtracey.com/pix/featured-photo.php"); ?>

so what happens if you put
<?
include('http://carlandtracey.com/pix/featured-photo.php');
?>

This is, like I say just a suggestion from somebody who knows very little about PHP and I may well be totally wrong here.

 
oddjob

Joined: 2003-01-09
Posts: 18
Posted: Fri, 2003-01-10 17:54

Hi
I have just read your last post, when I originally set my site up it was in the format index.html and my host told me if I wanted to to use php includes in an html page I had to do the following:-
1. create new text file .htaccess

2. edit .htaccess:

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html .phtml

3. As a result PHP will work with *.htm *.html *.php *.phtml

4. Upload .htaccess file to your /htdocs directory

Now this worked for me before I redid my whole site in php but I don't know whether it will work for you, maybe somebody with a bit more experience with php could step in here.

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Fri, 2003-01-10 19:32

Okay. So many questions! :roll:

oddjob:

Quote:
Thanks for taking the time to reply I have the $GALLERY_BASEDIR left as default because my gallery is in directory gallery and if I use include("${DOCUMENT_ROOT}/gallery/featured-photo.php"); that gets the photo onto the page but it has an error message preceding it :-
Warning: Cannot send session cache limiter - headers already sent (output started at /pub/home/********/htdocs/index.php:14) in /pub/home/********/htdocs/gallery/session.php on line 51

Okay. This is happening because you probably have another Gallery item on the same page (maybe a random block)? In any case, you're double-calling some code.

To fix this, comment out line 60 of featured-photo.php:
require($GALLERY_BASEDIR . "init.php");

fay:

Quote:
how to customize featured-photo.php to :

1) change the thumbnail to our own width and height? put width="xx" height="xx" to where? any sample?

I just call the Gallery thumbnail code, which specifies the width and height automatically. You'll have to change this on line 78:
from
$album->getThumbnailTag($index)
to
$album->getThumbnailTag($index, 234)

Where 234 is your new (long) dimension. Notice this will display a browser-resized image, which is usually pretty low quality.

carlandtracey.com:

dodofreak's advice is correct. You must use FULL PATHS in the include() and NOT URLs (which will not link you with PHP code... I don't understand how oddjob got the include to work with a URL!).

So you should be using something of the form:
include("/the/full/path/to/my/web/directory/gallery/featured-photo.php");
or, this should accomplish the same:
include("${DOCUMENT_ROOT}/gallery/featured-photo.php");

oddjob's advice of re-mapping HTML files to the PHP engine (the post directly above) is correct if the page you're including the include on is a html page and not PHP (after all, how would a PHP include work on a non-PHP page... :smile: ).

-Beckett (

)

 
Carl_in_Florida
Carl_in_Florida's picture

Joined: 2003-01-07
Posts: 110
Posted: Fri, 2003-01-10 20:36
Quote:
Hi
I have just read your last post, when I originally set my site up it was in the format index.html and my host told me if I wanted to to use php includes in an html page I had to do the following:-
1. create new text file .htaccess

2. edit .htaccess:

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html .phtml

3. As a result PHP will work with *.htm *.html *.php *.phtml

4. Upload .htaccess file to your /htdocs directory

Now this worked for me before I redid my whole site in php but I don't know whether it will work for you, maybe somebody with a bit more experience with php could step in here.

I would love to find out how to do this. Next week sounds like the time to find out. :smile:

 
dodofreak
dodofreak's picture

Joined: 2002-12-09
Posts: 75
Posted: Fri, 2003-01-10 21:43
Quote:
>>Hi
I have just read your last post, when I originally set my site up it was in the format index.html and my host told me if I wanted to to use php includes in an html page I had to do the following:-
1. create new text file .htaccess

2. edit .htaccess:

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html .phtml

3. As a result PHP will work with *.htm *.html *.php *.phtml

4. Upload .htaccess file to your /htdocs directory

Now this worked for me before I redid my whole site in php but I don't know whether it will work for you, maybe somebody with a bit more experience with php could step in here.<<

I would love to find out how to do this. Next week sounds like the time to find out. :smile:

Carl,

There are basically two options you have:

1. Rename whatever webpage you have from webpage.html to webpage.php
You need to have the .php extension so that the webserver will pass your file to the
PHP preprocessor.

or

2. Do the .htaccess steps listed above. I think that should work, especially if you need
to keep your .html extension for whatever reason.

Good luck! :smile:

 
daser

Joined: 2003-01-11
Posts: 2
Posted: Sat, 2003-01-11 21:22

I keep getting the following error:

Fatal error: Call to undefined function: fs_fopen() in /home/fademark/public_html/gallery/featured-photo.php on line 63

anyone know how to fix?

thanks

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Sat, 2003-01-11 22:41

daser,
This probably means you haven't correctly set the $GALLERY_BASEDIR variable in Line 24.

It's default is set to: $DOCUMENT_ROOT . "/gallery/",
but you might need to change it to the full path to your gallery directory if yours resides somewhere else.

-Beckett (

)

 
oddjob

Joined: 2003-01-09
Posts: 18
Posted: Sun, 2003-01-12 09:12

Hi Beckett
Just like to say thanks for this mod and for the help in getting it up and running, I know I can't get it running as designed but it works and that is the main thing.

Thanks again
Ian
<!-- BBCode Start --><A HREF="http://www.ianhardy.net" TARGET="_blank">www.ianhardy.net</A><!-- BBCode End -->

 
pbyjp
pbyjp's picture

Joined: 2002-11-12
Posts: 260
Posted: Sun, 2003-01-12 09:25

Yep!
Thanks Beckett for your help in general and this cool mod.
Will try to implement it next week.
will let you know.

Guys, just imagine this forum without Beckett (and a few others...)
God!! :eek:

p

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Sun, 2003-01-12 20:45

Glad I can do a little bit to help! :smile:

 
daser

Joined: 2003-01-11
Posts: 2
Posted: Sun, 2003-01-12 20:54
Quote:
daser,
This probably means you haven't correctly set the $GALLERY_BASEDIR variable in Line 24.

It's default is set to: $DOCUMENT_ROOT . "/gallery/",
but you might need to change it to the full path to your gallery directory if yours resides somewhere else.

-Beckett (

)

Unfortunately. that doesn't seem to be the problem. I had it set already.

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Sun, 2003-01-12 21:18

Okay. Then please provide:

- A link to the page with your block
- The full path to your Gallery
- The line from featured-photo.php where you have $GALLERY_BASEDIR

Thanks,
-Beckett (

)

 
Carl_in_Florida
Carl_in_Florida's picture

Joined: 2003-01-07
Posts: 110
Posted: Mon, 2003-01-13 21:19

Just wanted to say thanks for the help. You never really know how many people will read these threads and implement the advise without having to ask a question.
<!-- BBCode Start --><A HREF="http://carlandtracey.com" TARGET="_blank">carl and tracey homepage</A><!-- BBCode End -->

 
kenfused

Joined: 2002-11-28
Posts: 19
Posted: Fri, 2003-01-24 05:31

THANKS!!
Got it to work.. Had to change "<?php include("featured-gallery.php"); ?>" noted to "featured-photo.php" and it worked

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
if ($gallery->user->isAdmin() &amp;&amp; !strcmp($label, "Photo")) {
showChoice("Feature Photo", "featured-photo.php",
array("set" => 1,
"set_albumName" => $myAlbum->fields["name"],
"index" => $i));
}
</TD></TR></TABLE><!-- BBCode End -->

Now just put a <?php include("featured-gallery.php"); ?> where you want it and it's plug and play! This is how it looked when I threw it into my site:

 
pbyjp
pbyjp's picture

Joined: 2002-11-12
Posts: 260
Posted: Sun, 2003-02-16 17:38

I know Beckett that you wrote earlier how to resize the thumbnail, but your code, as you said, was only resizing the thumbnail from the thumbnail image, so if you wanted to make the image bigger, it wouldbe all pixelly.
Well, would there be another way to resize it?
I tried calling the getPhotoTag, but then could only get the full size photo. couldn't manage add any arguments to the function to choose my size.
my thumbnail are 180pb large and I want a 320px large featured photo...
What could I do?
is there a resizing function that we could put under the getthumbnail, that would scale it down or smth?
thanks for your help.
p

 
Jmallow
Jmallow's picture

Joined: 2003-02-19
Posts: 10
Posted: Wed, 2003-02-19 12:58

http://www.mallowweb.com/gallery/featured-photo.php

I am getting this error:
Fatal error: Failed opening required '/gallery/init.php' (include_path='.:/usr/share/pear') in /home/www/html/gallery/featured-photo.php on line 60

 
rmaz

Joined: 2003-02-20
Posts: 2
Posted: Thu, 2003-02-20 15:52

beckett quoting oddjob:

Quote:
>>
Warning: Cannot send session cache limiter - headers already sent (output started at /pub/home/********/htdocs/index.php:14) in /pub/home/********/htdocs/gallery/session.php on line 51
<<

Okay. This is happening because you probably have another Gallery item on the same page (maybe a random block)? In any case, you're double-calling some code.

I would say that this is actually related to Gallery trying to start a session (which means sending out a cookie) in a page that is already being sent. I realize that this is no longer an issue for oddjob, but in case somebody runs into it again (can't include('http://...'), for example), here's a solution:

Use output buffering in the page where you want to display a featured-photo block:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE><!-- BBCode Start --><A HREF="http://www.php.net//manual/en/function.ob-start.php" TARGET="_blank">ob_start()</A><!-- BBCode End -->;
include('gallery/featured-photo.php');
$featuredPhoto = <!-- BBCode Start --><A HREF="http://www.php.net/manual/en/function.ob-get-contents.php" TARGET="_blank">ob_get_contents()</A><!-- BBCode End -->;
<!-- BBCode Start --><A HREF="http://www.php.net/manual/en/function.ob-end-clean.php" TARGET="_blank">ob_end_clean()</A><!-- BBCode End -->;</TD></TR></TABLE><!-- BBCode End -->
Then, you have your featured-photo block in the variable, and you can echo($featuredPhoto) wherever you like in your page. NOTE: to avoid this cookie problem, you must put the code above before you start any output, before anything is sent to the browser. Ideally, you start with that code at the top of your page.

I believe there is another another possibility (but I didn't test it): to use output buffering for your entire page (I would think that in that case, headers get sent when you include('featured-photo.php'), but all output, including stuff generated before that include(), gets sent only when the script has finished running. Output buffering may also be used for compressing pages, wich could be interesting when your server has a slow connection.

The iFrame solution mentioned elsewhere is a good one, too :smile:

Anyway, good job on this feature, beckett!

 
oddjob

Joined: 2003-01-09
Posts: 18
Posted: Fri, 2003-02-21 08:26
Quote:
I would say that this is actually related to Gallery trying to start a session (which means sending out a cookie) in a page that is already being sent. I realize that this is no longer an issue for oddjob, but in case somebody runs into it again (can't include('http://...'), for example), here's a solution:

Use output buffering in the page where you want to display a featured-photo block:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE><!-- BBCode Start --><A HREF="http://www.php.net//manual/en/function.ob-start.php" TARGET="_blank">ob_start()</A><!-- BBCode End -->;
include('gallery/featured-photo.php');
$featuredPhoto = <!-- BBCode Start --><A HREF="http://www.php.net/manual/en/function.ob-get-contents.php" TARGET="_blank">ob_get_contents()</A><!-- BBCode End -->;
<!-- BBCode Start --><A HREF="http://www.php.net/manual/en/function.ob-end-clean.php" TARGET="_blank">ob_end_clean()</A><!-- BBCode End -->;</TD></TR></TABLE><!-- BBCode End -->
Then, you have your featured-photo block in the variable, and you can echo($featuredPhoto) wherever you like in your page. NOTE: to avoid this cookie problem, you must put the code above before you start any output, before anything is sent to the browser. Ideally, you start with that code at the top of your page.

Hi Rmaz
:grin: I just tried your solution and after initially not being able to get it to work (I didn't have the echo statement right :oops: ) it now work great, Thanks for taking the time to post your code it is appreciated. I now have the photo of the day at <!-- BBCode Start --><A HREF="http://www.ianhardy.net" TARGET="_blank">ianhardy.net</A><!-- BBCode End -->

Cheers
Ian :grin:

 
pbyjp
pbyjp's picture

Joined: 2002-11-12
Posts: 260
Posted: Sun, 2003-02-23 11:31

YEP!! I finally got it. :lol:
I managed to work out 2 ways to rescale the featured photo.
one of them is fully integrated to featured photo, the other one is fully INSPIRED by featured photo.
as always, there are probably many ways to do it another way or to customize the following script.
Please play with it, adapt the html to your own needs and if you have questions, well, we ll try to answer them.
I wanted to have my featured photo on my website's front page. and I wanted it bigger than the thumbnail's size in my albums. I actually use the featured photo script as a "latest picture uploaded" workaround.

1st solution, integrated to featured photo.

instead of having featured-photo.php call the thumbnail of the photo you featured, we have it call the path of the photo you featured, i.e instead of using getThumbnailTag(), we use getPhotoPath() which allows us to enclose the path in the IMG tag and use the height or width attributes to resize it the way you want.

line 78 of featured-photo.php
replace:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $IMG = "<a href="$PHOTO_URL">" . $album->getThumbnailTag($index) . "</a>"; </TD></TR></TABLE><!-- BBCode End -->

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $IMG = "<a href="$PHOTO_URL">" . "<img src=" . $album->getPhotoPath($index) . " width=250 >" . "</a>"; </TD></TR></TABLE><!-- BBCode End -->

Then you can customise this img tag to add a border or anything else.
The only downside to wanting your featured photo another size then the thumbnail one is that, by calling the path and not the tag, you actually download the resized photo. So a bit longer to download. In my case, my full size pictures are only 640x480 so it s not too much of a wait.
you will still need to install featured-photo.php on your gallery and get it to work.

2nd solution, inspired by featured photo.
This solution doesn t actually use the drop down menu under the thumbnail.
Because in my case I use featured photo more as a way to show the latest uploaded photo on my main page. Im my case, I always highlight the latest picture uploaded as the first gallery album on the main gallery page.
So this modification reuses the featured photo code to call the first thumbnail of the main gallery page. In this case it is a bigger size, and it is a thumbnail so you don t have to download the resized picture, but only a thumbnail, in my case width=250.
I coupled the code with some lines of code from albums.php where the gallery thumbnail get called.

of the box, without cleaning featured-photo.php from useless bits in our 2nd case, you can just replace again line 78 of the original featured-photo.php by the following:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $scaleTo = $gallery->app->highlight_size;
$highlightIndex = $album->getHighlight();
if (isset($highlightIndex)) {
list($iWidth, $iHeight) = $album->getThumbDimensions($highlightIndex, $scaleTo);
} else {
$iWidth = $gallery->app->highlight_size;
$iHeight = 100;
}
$gallery->html_wrap['thumbWidth'] = $iWidth;
$gallery->html_wrap['thumbHeight'] = $iHeight;
$gallery->html_wrap['thumbTag'] = $album->getHighlightTag($scaleTo);
$gallery->html_wrap['thumbHref'] = $albumURL;

$tag = $gallery->html_wrap['thumbTag'];
$href = $gallery->html_wrap['thumbHref'];
$IMG = "<a href="$PHOTO_URL">" . $tag . "</a>"; </TD></TR></TABLE><!-- BBCode End -->

Again, you can fully customise that to your needs. and clean up the bits of code you are not using.

I hope that gives you answers and now ideas.
Have fun.
Send your website addresses when you got it to work.

( my temporary one is <!-- BBCode Start --><A HREF="http://www.in-duce.net/demo/" TARGET="_blank">here</A><!-- BBCode End -->.
The site is in the making but I provide you with the link to have a look.
most features are not working or are not yet integrated or embedded. )

p

 
adams

Joined: 2003-03-27
Posts: 18
Posted: Tue, 2003-04-22 06:08

I have mine embeded in an other application and I suspect $set is used by that other application. So I had to add

$set = $_GET['set'];

right before the $set check to get it to work.

 
Dlur

Joined: 2003-04-17
Posts: 13
Posted: Tue, 2003-04-22 15:52

I've tried this out in one of my galleries. I set the $GALLERY_BASEDIR correctly in featured-photo.php and added the code into the proper location in view_album.php. I haven't bothered to do an include on my home page yet because when I try to set a featured photo while logged in as admin I get a pop-up window that just sits there blank like this:
<!-- BBCode Start --><IMG SRC="http://www.homelandmud.org/Jim/gallery/albums/miscjunk/Clipboard01.jpg"><!-- BBCode End -->

My gallery is located at http://www.homelandmud.org/Jim/gallery

I'm running on Windows 2000 server with IIS 5 and PHP 4.3.1 and Gallery version 1.3.3

Yes I do realize that IIS is unsupported, but just wondering if this is a generic problem that might be easily solved somehow. I'd really like to get this working as it will really add to one of my other gallery's functionality. Yes I realize that Windows sucks for php in general, especially with IIS, but you gotta use what you have sometimes. Gallery is the only product out there that I've been able to find that can do the things that it does.

Also note that the code for <!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpWiki&amp;file=index&amp;pagename=Random%20Block%20-%20Top%2010%20Albums%20and%20Last%205%20Updated%20Albums%20Block%20Hack" TARGET="_blank">Random-photo block, album top 10, and last updated</A><!-- BBCode End --> works just fine as witnessed by <!-- BBCode Start --><A HREF="http://www.homelandmud.org/jim/index.htm" TARGET="_blank">this page.</A><!-- BBCode End -->