Inline image sizing

  • Thread starter LoudMusic
  • 15 comments
  • 1,095 views
10,687
United States
Everywhere
I couldn't find a previous referance, but is there a way or could there be a way in the future to size images referanced from other sites? Sometimes we find images that are really cool, but really huge. It would be nice to make them 600 px wide (and let the hight fit proportionately) so that we don't get a horizontal scrollbar.

Infact! I think it would be cool if we could have them defaultly go to that size (maybe 800) and have settings similar to the font system. Small, medium, large. That way people won't be able to hack it and make images huge and obnoxious. Heck, I could attach an image that was a bazillion pixels in both directions and only a few kilobytes. Some code that forces a maximum size would be handy (:
 
Yep, you can do this, but only for attached images. You would use the PHP function GetIMageSize(), to make a decision, then calculate an aspect ratio, then write the new size into the attachment display image tag.
 
Well, it doesn't really have to be a resize of the image in the file, but using html you could set its display size.

Code:
<img src="something.jpg" width="600">

And the like ...
 
Yeah. but you would only want to do that if the image was outside of its constraint. What if someone posted an icon? You wouldn't want it resized to 600px, would you?

So, you get the size of the image, then work out the aspect ratio, then if it's over 600px wide, you put this into the <img> tag:

PHP:
<img src="something.jpg" <?php 
if($hsize > 600)
{
    echo "width=\"600\" height=\"".($vsize * $aspect)."\"";
}
?>>

Thus you get PHP to dynamically set the height and width attributes.
 
OOoohhh, sorry, I've got a lot going on right now. I totally read your post wrong.

Yes, it would only need to apply sizing tags to images too large. You are correct.

(:

By the way, from one sys admin to another, don't ever take a job administrating Lotus Domino / Notes. It will be the bane of your existance.
 
Originally posted by LoudMusic
OOoohhh, sorry, I've got a lot going on right now. I totally read your post wrong.

Yes, it would only need to apply sizing tags to images too large. You are correct.

(:

By the way, from one sys admin to another, don't ever take a job administrating Lotus Domino / Notes. It will be the bane of your existance.
Heh! I don't think I ever would. I'm not sure that any of my company's clients use it. We're all about Exchange.

Anyway, I'm moving away from the hardcore tech stuff and concentrating on the Project Management and Project Delivery side.

Which is nice, especially when I pull the "tech guns" out, and blow the Technical Architects away! :sneaky-laugh:

Now my hard-core tech stuff is almost all PHP development, which I'm using for personal projects.
 
Well, keep in mind it would be nice to have a way to fix a maximum size (and even specify that in the user options pannel) and also a way for the person making the post to set a size, similar to the fonts deal.
 
I have seen some code modifications that do this, Giles, it has been done. There is a chance I'll add it in with GTP6, although I'm not sure yet. It would be handy at times...
 
Correct, but it wouldn't blow the web page out of proportion. You know when you get a horizontal scroll how irritating that is?
 
Sorry to resurrect this ancient thread, but i was hit by this yesterday, trying to scale down a big image. Maybe there are new methods hiding (i didn't find any except auto image resizing), as i see it there are two possibilites to scale images on GTPlanet
Maybe a bbcode addon like [IMG size=50%]url[/IMG] with restriction to less than 100% and a HMTL/CSS solution like

http://stackoverflow.com/questions/8397049/css-image-resize-percentage-of-itself

would do the job of taming big images found on the web without uploading them to your servers or proxying them through somebody.

What do you think?
 
Last edited:
This type of image resizing is already implemented here - any image wider than the post area will be automatically resized to fit, whether you upload it as an attachment or hotlink it from somewhere else. With attached images uploaded to your post here, you have the additional option of inserting a thumbnail, which only loads the larger version when clicked.
 
This type of image resizing is already implemented here - any image wider than the post area will be automatically resized to fit, whether you upload it as an attachment or hotlink it from somewhere else. With attached images uploaded to your post here, you have the additional option of inserting a thumbnail, which only loads the larger version when clicked.

I think you misunderstood my intention to specify the image scaling myself, not automatically. I wanted to use the bbcode IMG to insert an image and scale it with a value between 1% and 99% (make it smaller both in width and height, keep the aspect ratio). The scaling should be just CSS code for the HTML img element, so that the image is scaled in the browser.

I think this could be made possible by adding an attribute 'size' to the IMG bbcode tag like [IMG size=50%]image.url[/IMG] (this is not parsed by the BBCode parser right now). This attribute could be incorporated in the generated HTML like in the stackexchange link in the previous post. No need to check the size of the image as in the ancient posts.

The percent value doesn't need to refer to the image size itself, but to the post width. So if i say 50%, i want the image to occupy 50% of the post's width, so i can have two images side by side.

Could this be implemented?
 
No, the IMG bbcode tag doesn't support parameters. Resizing the image on your own will be the best option to control its size.
 
Back