Help - Search - Members - Calendar
Full Version: Smarter way of image pop-ups?
Movable Type Community Forum > Using Movable Type > Additional Features
quadsk8
Hello all,

I have searched the forum for my following question but could not find a thread about it (please tell me if there is)

While things are going really good with my Blog smile.gif, it seems that the space on my server is becoming rather spare sad.gif . I looked at all the large images, moved them elsewhere on the net, but also found 111 kb of pop-up files.

My Uploaded Pop-up Image Template uses, as all other templates, PHP files. When I look inside the generated files, the only 3 differences between them are the URL of the image, its width and its height.

This does not seem a very smart way of coding, would somebody have a better way (PHP?) to make pop-ups with only ONE file for all images?

(or maybe even without a separate file at all?)
gramcracker
You could use a template file and pass the variables through with PHP--use a GET or POST, with variables like:

CODE
http://www.mysite.com/popup.php?file=myfile.jpg&width=800&height=600


And then in the template, you'd have it open $file with $width and $height.

You could also do something with a Javascript function...

openPopup(filename,width,height)
{code}

and then in the link, you would just do onClick=openPopup(myfile.jpg,800,600).
quadsk8
Thank you gramcracker (and girlie?),
that puts me in the right direction, but
(there seems to always be a but...)

The pop-up code is somewhat more complicated to make a link work with a browser without javascript, I made it with your advise to the following:
CODE
<a href="http://www.mysite.com/popup.php?file=http://www.mysite.com/image.jpg&width=800&height=600"
onclick="window.open('http://www.mysite.com/popup.php?file=http://www.mysite.com/image.jpg&width=800&height=600', 'popup', 'width=800,height=600,scrollbars=no,resizable=no,toolbar=no,directories=no,lo
cation=no,menubar=no,status=no,left=0,top=0');
return false">pop up this image</a>


And for some reason this does not work.

I used in the popup.php the following line:
CODE
<img src="<? $file ?>" width="<? $width ?>" height="<? $height ?>" border="0" onClick="javascript:window.close();>

is that correct?

What happens is that the window gets closed without showing any pop-up.

Lawrence
gramcracker
Hmmm.  Try taking it apart a step at a time.

First try doing the popup just as a javascript-enabled link, so you can figure out if it's the javascript code that's not working, or the PHP.  When the popup.php opens, check the source code.  Are the variables filled in as they should be?

Also, try getting rid of the window.close() stuff.  See if that's making it hiccup.

Simplify it down, and then see if you get anywhere.
quadsk8
Aha, it works. Still not perfectly, but this is a matter of tweaking.

simplified the call to
CODE
<a href="http://www.mysite.com/popup.php?file=http://www.mysite.com/image.jpg&width=800&height=600" target="_blank">


And corrected the fault in above mentioned frase of the popup.php:
CODE
<img src="<? echo $file ?>" width="<? echo $width ?>" height="<? echo $height ?>" border="0">


Thanks for your support!
Lawrence
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.