![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
Any good with javascript?
I have some blog entries imported that include images. Some of the images exceed the width of the column. The column is 450 pixels that I'm working with. If possible I would like a way to detect the image size onload and resize it to 450 if it's width is greater. Like the images on this forum do.
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
Testing ...
![]()
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
<&(©¿©)&>
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
|
don't be lazy, just look in the source html of this board to see how it's done...
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000 Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager ![]() Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
fine woj, help me out then! :p
here's what I'm trying to do.. http://www.clickmojo.com/imagetest.html I'd like to make it something I can just put in the header that will automatically resize images inside the div id = post so I don't have to edit each image entry. If I can't do it that way... I'd like to make it as easy as possible so I can just add a small function to each image like .. onload = ' imgResize ' and onclick = ' imgFull ' or something of that nature.
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Too lazy to set a custom title
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
|
Play with this.. I put it in a page onLoad event and it worked ok in Opera. Didn't test it in other browsers. Keep in mind the images will look crappy.
for(i=0;i<document.images.length;i++){ if(document.images[i].width > 450){ document.images[i].width=450; } } |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
Tempest, I'm using Opera too.. check this out.. very nice solution but probably doesn't work for IE.
![]() style = max-width:450
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
Found an IE fix, using 'expression' css
So like; Code:
#thepost img { width:expression( document.body.clientWidth > 450? "450px": "auto" ); max-width:400px; }
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Too lazy to set a custom title
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
|
Nice... Can you do the clicking thing??
var oldwidths=new Array(); var maxwid=450; function resimgs(){var i;var img; for(i=0;i<document.images.length;i++){ img=document.images[i]; if(img.width > maxwid){ oldwidths[img.name]=img.width; img.width=maxwid; } } } function clkimg(img){ if(img.width > maxwid){ img.width=maxwid; }else if(oldwidths[img.name]){ img.width=oldwidths[img.name]; } } for the body tag onLoad="resimgs();" for each applicable image <img src="" name="img1" onClick="clkimg(this);"> each image has to have a unique name. The one problem is that this solution will curently resize ANY image (including banners).. You could put in a name check though and make sure any images you possibly want resized start with a string that you would check for. Let me know if you need that code as well. Works in IE, Opera, Netscape 7 and 8 but my Firefox is broken so couldn't test it. Clicking on the images toggles between full and min size. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
I appreciate the brainstorming
![]() If I could add a clickable link without having to edit the img src tags, that would rock. I'm not sure if the 'expression' will allow that.
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Too lazy to set a custom title
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
|
well.... if you don't want to change the current page source, then you'd have to hack in some code to do a global click event and then filter it down to just the images within the div... but... you probably lose the original image size by using the style so there wouldn't be any way to size it big again...
|
![]() |
![]() ![]() ![]() ![]() ![]() |