Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-27-2008, 07:47 AM   PM User | #1
joshua7
New Coder

 
Join Date: Apr 2008
Posts: 25
Thanks: 4
Thanked 0 Times in 0 Posts
joshua7 is an unknown quantity at this point
Don't display an image until is completely downloaded

In my site when you add a very large image to a post and then you see that post, the image downloads in its actual size and then resizes to the size I allow.

I've noticed in a website that large images aren't displayed until they load completely. So if the image is huge you don't see a thing until it is completely downloaded.

Is this possible to accomplish with javascript?
joshua7 is offline   Reply With Quote
Old 08-27-2008, 08:05 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,036
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Pre-load the image, then display it.
Philip M is offline   Reply With Quote
Old 08-27-2008, 08:44 AM   PM User | #3
rhinodog8
New Coder

 
Join Date: Aug 2008
Location: Colfax, California USA
Posts: 64
Thanks: 3
Thanked 5 Times in 5 Posts
rhinodog8 is an unknown quantity at this point
you could have the style set to none and onload have the display set to block

display being a css property.
rhinodog8 is offline   Reply With Quote
Old 08-27-2008, 01:40 PM   PM User | #4
lipsigprice
Banned

 
Join Date: Aug 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
lipsigprice is an unknown quantity at this point
display Image after Pre-load the image
lipsigprice is offline   Reply With Quote
Old 08-27-2008, 05:41 PM   PM User | #5
joshua7
New Coder

 
Join Date: Apr 2008
Posts: 25
Thanks: 4
Thanked 0 Times in 0 Posts
joshua7 is an unknown quantity at this point
Quote:
Originally Posted by rhinodog8 View Post
you could have the style set to none and onload have the display set to block

display being a css property.
do I have to specify image sources this way?
Because images are supposed to be uploaded randomly by the community.
joshua7 is offline   Reply With Quote
Old 08-27-2008, 06:18 PM   PM User | #6
Cranford
Banned

 
Join Date: May 2005
Location: Midwest, U.S.
Posts: 118
Thanks: 1
Thanked 26 Times in 23 Posts
Cranford is an unknown quantity at this point
I'd avoid the problem altogether. Don't use JavaScript to re-size images. Use your server language. If your host supports PHP, then post an appropriate question in that forum. PHP has some excellent image manipulation functions that will maintain the aspect ratio, color density, etc. You can manipulate the image as soon as it's uploaded. You can create a temporary page, for your use only, to re-size all existing images. This way, all images load in a reasonable amount of time.
Cranford is offline   Reply With Quote
Old 08-27-2008, 08:27 PM   PM User | #7
joshua7
New Coder

 
Join Date: Apr 2008
Posts: 25
Thanks: 4
Thanked 0 Times in 0 Posts
joshua7 is an unknown quantity at this point
Ok I understand. Uploaded images shouldn't be a problem this way.
What can I do about images posted through bb code?
joshua7 is offline   Reply With Quote
Old 08-27-2008, 08:37 PM   PM User | #8
Cranford
Banned

 
Join Date: May 2005
Location: Midwest, U.S.
Posts: 118
Thanks: 1
Thanked 26 Times in 23 Posts
Cranford is an unknown quantity at this point
You've posted twice now, and still can't bring yourself to write "thank you" in response to ANYONE who took the time to help you. I'm finished.
Cranford is offline   Reply With Quote
Users who have thanked Cranford for this post:
Philip M (08-30-2008)
Old 08-27-2008, 08:44 PM   PM User | #9
rhinodog8
New Coder

 
Join Date: Aug 2008
Location: Colfax, California USA
Posts: 64
Thanks: 3
Thanked 5 Times in 5 Posts
rhinodog8 is an unknown quantity at this point
Quote:
Originally Posted by joshua7 View Post
do I have to specify image sources this way?
Because images are supposed to be uploaded randomly by the community.
No it would be a css class that would be automatically applied to any uploaded image.

Last edited by rhinodog8; 08-28-2008 at 09:56 AM..
rhinodog8 is offline   Reply With Quote
Users who have thanked rhinodog8 for this post:
joshua7 (08-28-2008)
Old 08-28-2008, 08:52 AM   PM User | #10
joshua7
New Coder

 
Join Date: Apr 2008
Posts: 25
Thanks: 4
Thanked 0 Times in 0 Posts
joshua7 is an unknown quantity at this point
I should change the class when the page loads right?
Something like:

Code:
<body onload="document.getElementById(  ).className = 'showimages';">

.showimages img {
display: inline;
}
joshua7 is offline   Reply With Quote
Old 08-28-2008, 10:02 AM   PM User | #11
rhinodog8
New Coder

 
Join Date: Aug 2008
Location: Colfax, California USA
Posts: 64
Thanks: 3
Thanked 5 Times in 5 Posts
rhinodog8 is an unknown quantity at this point
yea, expect you'd use:
Code:
onload="getElementByClass('imgclass').style = 'display: block'"
and i don't know for sure but I think you can use onload to images, and just have you server/php/forum/whatever have it insert that code in posts and inbetween <img></img> tags.

and have the img class be(in CSS)
Code:
.imgclass {display:none;}

Last edited by rhinodog8; 08-28-2008 at 10:20 AM..
rhinodog8 is offline   Reply With Quote
Old 08-28-2008, 10:03 AM   PM User | #12
rhinodog8
New Coder

 
Join Date: Aug 2008
Location: Colfax, California USA
Posts: 64
Thanks: 3
Thanked 5 Times in 5 Posts
rhinodog8 is an unknown quantity at this point
Sorry, duplicate post, can't seem to delete it.

Last edited by rhinodog8; 08-28-2008 at 10:10 AM..
rhinodog8 is offline   Reply With Quote
Old 08-28-2008, 05:23 PM   PM User | #13
joshua7
New Coder

 
Join Date: Apr 2008
Posts: 25
Thanks: 4
Thanked 0 Times in 0 Posts
joshua7 is an unknown quantity at this point
ok thanks so much rhinodog8!
joshua7 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:57 AM.


Advertisement
Log in to turn off these ads.