Log in

View Full Version : Print Image in an imageholder



cyote101
03-18-2010, 10:08 PM
Hi all. New to the forum.... I checked it out early this morning and liked the stuff you guys have. So i thought i would check with you about my problem.

First off. I'm just learning css and xhtml so this is a learning experience.

So here is my challenge. I making a site with 1000s of images. I would like to make a template for all my pages that will hold one image each. So there will be 100s if not 1000s of such pages. So what i'm trying to do is create a script that will print what ever image is inside an image holder called "Main Image" I would like to place a button on each page that when pressed will print what ever image is in the image holder, I think it's technically called an image place holder.

Well I hope that makes sense. I'm also trying to do the same thing for an email and bookmark button. Thanks for your time.:)

BLiZZaRD
03-18-2010, 11:11 PM
Well, you can do it with CSS... in a way. Using the @media parameter, basically you take all the content you have on the page and set it to display: none, leaving only the Main image content visible. Like so:



# @media print
# {
# body{font-family:georgia,times,sans-serif;}
# #left{display:none;}
# #center{display:none;}
# #right{display:none;}
# #Main_Image{display:block;}
# }
#
# @media screen
# {
# body{font-family:arial,verdana,sans-serif;}
# #left{display:block;margin:20px;}
# #center{display:block;margin:20px;}
# #right{display:block;margin:20px;}
# #Main_Image{display:block;margin:20px;}
# }


The above assumes you have 4 ID's on your page, "left", "center", "right" and "Main Image". When the print button is pressed, the printer "sees" only the "Main Image" div (table, whatever) and that's all it prints.

cyote101
03-18-2010, 11:53 PM
wow, cool.

Now does that make it so the image or only visable item is scaled up or down to fit the print media?

Thanks, I will play with that and see how it goes. I'll let everyone know

BLiZZaRD
03-19-2010, 02:19 AM
I don't use it, so your test will tell you more than I can. However, the code suggest that everything stays size oriented. the printer actually IS printing all items on the page, as far as the printer is concerned. The thing is that everything except what you don't want printed is "invisible" to the printer, so no ink is being put on the paper in that spot.

cyote101
03-20-2010, 08:17 AM
Thanks for your info,

is it not possible to print just a div or something?