PDA

View Full Version : Attached Image Popup fit to Image Specs



epic1
Tue 31st May '05, 12:15am
I've done over 20 searches, still cannot find how to do this.

I have my attachments open in a new window via target="_blank". That's all good and done.

I need the popup window to fit to the image's size. I have both scripts I need to use to do this, I just don't know how to go about putting them together in the correct manner via the template manager.

Code snippet 1 within Showthread template header:



<script language="javascript" type="text/javascript">
function PopupPic(sPicURL) {
newWin=window.open( sPicURL, 'newWin',
'resizable=1,HEIGHT=200,WIDTH=200');
newWin.focus();
}
</script>

Code snippet 2...no clue where to put this:



<html>
<head>
<title></title>
<script language="javascript" type="text/javascript">
var NS = (navigator.appName=="Netscape")?true:false;
function FitPic() {
iWidth = (NS)?window.innerWidth:document.body.clientWidth;
iHeight = (NS)?window.innerHeight:document.body.clientHeight ;
iWidth = document.images[0].width - iWidth;
iHeight = document.images[0].height - iHeight;
window.resizeBy(iWidth, iHeight);
self.focus();
};
</script>
</head>
<body bgcolor="#000000" onload="FitPic();" topmargin="0"
marginheight="0" leftmargin="0" marginwidth="0">
<img src="$image&amp;id=$id" border="0" alt="" />
</body>
</html>

It does open the attachment in a new 200x200 window, but it does not resize since I'm stumped on where to put the second code tidbit.

Any help would be greatly appreciated!

Jake Bunce
Tue 31st May '05, 1:43am
You have code within your page head, so you should add that code to the headinclude template.

I don't know what to do with the rest of that code since I am not familiar with it.

epic1
Tue 31st May '05, 2:48am
Are any other options available to achieve this auto-resize window for the attached image in the popup?

I know vBGarage can do this, as this is using the popup code mentioned above, however it ties in a seperate template for the new window (what Code snippet 2 refers to).

Is there a way to call upon a new template that passes over the image as a string of some sort?

I'd be greatful to any suggestions as I hate having unnecessary space filling the surrounding image attachments in their new windows.

Jake Bunce
Tue 31st May '05, 5:26am
I don't know of any way to do this. :(

WetWired
Tue 31st May '05, 10:32am
Normally, attached pictures are shown without a page (there is no HTML in the popup window). You need to either have the popup JS open an about:blank, then write a page with your special resize code in it (which I have no idea how to do, but know that it can be donw), or add a new PHP page to create the page with your script and the propper image.

keithxtreme
Sat 27th May '06, 2:09am
I've done over 20 searches, still cannot find how to do this.

I have my attachments open in a new window via target="_blank". That's all good and done.

I need the popup window to fit to the image's size. I have both scripts I need to use to do this, I just don't know how to go about putting them together in the correct manner via the template manager.

Code snippet 1 within Showthread template header:



<script language="javascript" type="text/javascript">
function PopupPic(sPicURL) {
newWin=window.open( sPicURL, 'newWin',
'resizable=1,HEIGHT=200,WIDTH=200');
newWin.focus();
}
</script>

Code snippet 2...no clue where to put this:



<html>
<head>
<title></title>
<script language="javascript" type="text/javascript">
var NS = (navigator.appName=="Netscape")?true:false;
function FitPic() {
iWidth = (NS)?window.innerWidth:document.body.clientWidth;
iHeight = (NS)?window.innerHeight:document.body.clientHeight ;
iWidth = document.images[0].width - iWidth;
iHeight = document.images[0].height - iHeight;
window.resizeBy(iWidth, iHeight);
self.focus();
};
</script>
</head>
<body bgcolor="#000000" onload="FitPic();" topmargin="0"
marginheight="0" leftmargin="0" marginwidth="0">
<img src="$image&amp;id=$id" border="0" alt="" />
</body>
</html>

It does open the attachment in a new 200x200 window, but it does not resize since I'm stumped on where to put the second code tidbit.

Any help would be greatly appreciated!

So you are putting that code in the SHOWTHREAD template? Are you then calling the JS with sPicURL from the postbit_attachment thumb template by replaing 'new window' with sPicURL?

At least having a window open that is not full screen would be better than nothing....