07-25-2014, 07:59 AM
|
#1
|
Franchise Player
Join Date: Feb 2006
Location: Calgary, AB
|
The problem with huge images
Every so often, someone posts an image that is massive and it screws up the format of the whole page.
I've been updating my own website and have added this simple style to my CSS so that images don't screw up page formatting on smaller screens. Images display at their normal size up to the point that they exceed the width of their container, then they shrink to stay contained.
Code:
img {
max-width: 100%;
height: auto;
}
Adding this to the forum's CSS should prevent those big images from screwing up the page. It won't prevent people from posting them, and it won't save the bandwidth used to download them, but at least it will stop pages from being thrown out of whack by them.
I assume you have some ability to edit the forum's CSS, and this would be a very simple edit that won't add any burden to the page and doesn't require any plugins or Javascript.
__________________
Turn up the good, turn down the suck!
|
|
|
07-25-2014, 11:06 AM
|
#2
|
CP Gamemaster
Join Date: Feb 2010
Location: The Gary
|
Alternately, is there also a way to let the large image only stretch that one post, and the rest retain the original size? Skyscraperpage does that and it's great.
|
|
|
07-25-2014, 02:10 PM
|
#3
|
The new goggles also do nothing.
Join Date: Oct 2001
Location: Calgary
|
Not with this forum software AFAIK Mazrim, or at least not without a much different template.
That's a good suggestion getbak, is there any potential downside? I can't think of any other than if there was something integral to the operation of the site that required images wider than the browser window but I don't think there are.
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
|
|
|
07-25-2014, 02:13 PM
|
#4
|
Franchise Player
Join Date: Feb 2006
Location: Calgary, AB
|
I don't believe there should be any downside. All images will display normally, this will just restrict those super-big ones from stretching too far. Since it's just CSS, it shouldn't have any impact on any other functions on the forum.
__________________
Turn up the good, turn down the suck!
|
|
|
07-25-2014, 02:26 PM
|
#5
|
The new goggles also do nothing.
Join Date: Oct 2001
Location: Calgary
|
Tried it and it fixes the big images, but for some reason it makes the icons in the editor disappear, so I reverted.
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
|
|
|
07-25-2014, 03:13 PM
|
#6
|
Franchise Player
Join Date: Feb 2006
Location: Calgary, AB
|
Ah, those images are in table cells without a defined width, so the max-width screws them up.
Try this:
Code:
.alt1 img {
max-width: 100%;
}
That will only affect images in the message display fields. I tested it in Chrome and it seems to work without affecting the icons.
__________________
Turn up the good, turn down the suck!
|
|
|
07-25-2014, 03:22 PM
|
#7
|
The new goggles also do nothing.
Join Date: Oct 2001
Location: Calgary
|
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
|
|
|
07-25-2014, 03:25 PM
|
#8
|
Franchise Player
Join Date: Feb 2006
Location: Calgary, AB
|
Woohoo!
__________________
Turn up the good, turn down the suck!
|
|
|
07-25-2014, 03:54 PM
|
#9
|
Franchise Player
Join Date: Feb 2006
Location: Calgary, AB
|
I noticed a couple of places where images have also disappeared because they're in td tags with the alt1 class and undefined width... - The Ivrnet logo at the top, and the "thread status icon" cell (the leftmost cell on the topics page) are both in cells with the "alt1" class but no defined size, so they disappear too.
- You could fix that either by changing the class on those cells to "alt2" (which seems to look exactly the same as "alt1"), or put a defined size on the img tags or the td cell.
I don't know how much control you have in editing those things.
__________________
Turn up the good, turn down the suck!
|
|
|
07-25-2014, 04:24 PM
|
#10
|
The new goggles also do nothing.
Join Date: Oct 2001
Location: Calgary
|
Good eyes, I took it back out for now. I might also be able to assign a class to the td cell for posts to reference that only, I'll have to look at the templates. I'll check it out.
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
|
|
|
07-26-2014, 06:04 AM
|
#11
|
Franchise Player
|
Quote:
Originally Posted by photon
|
That image still stretches the page for me in Chrome, FWIW.
EDIT: Whoops, looks like this is still a work in progress.
|
|
|
07-26-2014, 03:25 PM
|
#12
|
Backup Goalie
Join Date: Mar 2006
Location: Calgary
Exp:  
|
What about using a CSS3 attribute selector, like so:
Code:
div[id^=post_message_] img { max-width: 100%; height: auto; }
(If you're not familiar with the syntax, this only targets divs with an ID of the form post_message_XXXX, regardless of what the numeric string is on the end of the ID).
Should work in all modern browsers, and even in IE7+. IE6 would be left in the cold, but it would be no worse for those users than it is at present.
|
|
|
The Following User Says Thank You to maverickstruth For This Useful Post:
|
|
07-27-2014, 11:16 AM
|
#13
|
The new goggles also do nothing.
Join Date: Oct 2001
Location: Calgary
|
That seems to work. I assume there's some kind of performance impact from using an attribute selector, but I also assume since we're only using one it probably isn't worth thinking about.
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
|
|
|
The Following User Says Thank You to photon For This Useful Post:
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -6. The time now is 11:54 AM.
|
|