Forum Moderators: not2easy

Message Too Old, No Replies

Conditional CSS

image tage issues

         

jvogt

4:52 pm on Jul 22, 2003 (gmt 0)

10+ Year Member



Wonder if anyone knows if this is possible:

I have some diagrams (png) that can get quite large and I have users that need to be able to print them. They print, but on multiple sheets of paper. What I am trying to do is scale them to 1 sheet. Setting the height/width properties of the IMG tag worked great but I only want the images smaller than a sheet of paper to be scaled.

Any ideas?

Jesse

Reflection

5:05 pm on Jul 22, 2003 (gmt 0)

10+ Year Member



You could try defining the height/width of your images in a print style sheet rather than in the img tag. If all the images are the same size give them a class and define the width/height in the print style sheet. If they are different sizes you will have to give each img an id.

To use a print style sheet:

<link rel="stylesheet" type="text/css" media="print" href="print.css">

DrDoc

5:48 pm on Jul 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmaster World!

If I were you, I would utilize the image functions provided by PHP, and let PHP build the print style sheet on the fly.

DrDoc

5:49 pm on Jul 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Come to think of it...
You could just make all your images fill a page in size... which means some would be enlarged, others smaller

rjohara

6:23 am on Jul 23, 2003 (gmt 0)

10+ Year Member



Sorry, I don't understand the question as you've asked it. You say that specifying height and width on the IMG element works. Isn't that what you want?

DrDoc

2:39 pm on Jul 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You say that specifying height and width on the IMG element works. Isn't that what you want?

What Jesse wants to know is how to know which images are too big to fit on one page, and how to resize those - only those.

bcolflesh

2:41 pm on Jul 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you do in fact have access to PHP, then:

us2.php.net/getimagesize

rjohara

5:22 pm on Jul 23, 2003 (gmt 0)

10+ Year Member



OK, I think I understand now. If you know your page size is 60em, or 600px, or whatever you like, then you can create a rule like:

img { max-width: 60em; max-height: 80em; }

You might be able to even use % and just say max-width: 100%

I'd poke around with variants like this. I've had good luck laying out images that will scale properly in text columns this way. (Usual caveat: not all browsers support max-width; I use Mozilla, which does.)

DrDoc

5:30 pm on Jul 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE doesn't support it properly...

jvogt

9:48 pm on Jul 23, 2003 (gmt 0)

10+ Year Member



Thanks for the ideas guys. The website is generated from a visual modeling tool and I was looking for a quick way to resize the images without having to modify the source too much. We publish the model fairly often so I was hoping to simply include a style sheet. I will probably just end up dealing with it since I don't want to be messing with the model too much (it is quite extensive and probably not worth the extra work).

Jesse