Gossamer Forum
Quote Reply
How to print image
Hey all,

Hope youre all doing well.

On my detailes page i have a image.
Id like for people to be able to print that image. Just that image. With a "Print Image" button. Not the print menu from the browser.
Ive been looking around and it seems that the only way is to open the image on a separate window and on that html have a javacript auto print, then close window.
I can open the new browser, but how do I make it html with the pic inside?

Or maybe there is a simpler way?

Tried via css print versión, but conflicts with the normal print version and couldnt get it just right.

Can anyone help?

Thanks,

Juan Carlos
Quote Reply
Re: [Gorospe] How to print image In reply to
Hi,

Yeah, what you would need to do, is have a page that opens with the image on - and then a little javascript, that opens the print:

Code:
window.print();

You may also need to get a bit more clever with it, in terms of using some code to detect if the image has finished loading (but you can play around with that, and see if thats needed, or if the browser will just wait for it to finish downloading)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to print image In reply to
Yeah, I know the basics. Ive searched around the web and found code that seems to work.
I cant make the image open on a window WITH html so I can place the javascript on it so it opens the dialogue.
Quote Reply
Re: [Gorospe] How to print image In reply to
The image opening is pretty simple.

Make a new template called print_image.html, with:

Code:
<html>
<head>
<title></title>
<script>
window.print();
</script>
</head>
<body>

<img src="<%image%>" />

</body>
</html>

then send them to that page using:

Code:
page.cgi?p=print_image;image=THE_IMAGE_URL

If you wanted to be a bit more secure, you could just pass the link ID, and then use my Load_Link function from ULTRAGlobals a call:

Code:
<%Plugins::ULTRAGlobals::Load_Link($ID)%>

that should then give you access to the whole link in the template (so you can show whatever image you want)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to print image In reply to
Ive got everything working, except the image does n ot showup on the page.
In the URL is fine.
On the print.html it doesnt show.
I think it may be that its not recognising the <%Plugins::ULTRAGlobals::Load_Link($ID)%> ?
Quote Reply
Re: [Gorospe] How to print image In reply to
You need to change the URL, to you are passing the ID =)

page.cgi?p=print_image;ID=<%ID%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How to print image In reply to
The URL passing now is: page.cgi?p=print_image;image=2
With 2 being the ID. But the image still doesnt show.
Looking at the print.html templete, the URL for the image is blank. So the print dialogue does open, but there is no content to print.
Am I not getting something?
Quote Reply
Re: [Gorospe] How to print image In reply to
Ok, I got it working now.
I had to pass Both, ID and Image URL.
I was first passing the url, and then the ID.
The final link from my detailed page is:
<a href="page.cgi?p=print_image;ID=<%ID%>;image=<%Plugins::Thumb_Images::get_path($ID,"Cupon","large","Links","url")%>">Print</a>
And it works just fine.


Thanks Andy.
Quote Reply
Re: [Gorospe] How to print image In reply to
Hi,

No you don't :)

Call with:

Code:
<a href="page.cgi?p=print_image;ID=<%ID%>">print image</a>

Then the template:

Code:
<html>
<head>
<%Plugins::ULTRAGlobals::Load_Link($ID)%>
<title></title>
<script>
window.print();
</script>
</head>
<body>

<%if ID%>
<img src="<%Plugins::Thumb_Images::get_path($ID,"Cupon","large","Links","url")%>" />
<%endif%>

</body>
</html>


Angelic

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
HRe: [Andy] How to print image In reply to
Hmmm now thats working too...
Ill try to figure out why.
But its working.
Thanks Andy. I like your version better since it doesnt show the url of the image. :)

Thanks.