How to make a thumbnail using javascript?

This is a discussion on "How to make a thumbnail using javascript?" within the JavaScript Forum section. This forum, and the thread "How to make a thumbnail using javascript? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 17th, 2008, 19:44
Junior Member
Join Date: Jan 2008
Location: Northern Ireland
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
How to make a thumbnail using javascript?

Now i don't have a clue about javascript lol.. But i want to know is it possible to make a thumbnail by putting in the full size image, instead of having 2 images (thumbnail AND full size)? If so, could someone please post a code or tutorial on how to do it?

Thanks.
Reply With Quote

  #2 (permalink)  
Old Jan 18th, 2008, 14:33
Junior Member
Join Date: Jan 2008
Location: Northern Ireland
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to make a thumbnail using javascript?

Anyone?!
Reply With Quote
  #3 (permalink)  
Old Jan 18th, 2008, 20:15
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to make a thumbnail using javascript?

The thumbnail will look terrible if it's resized by javascript/html... it will be all squishy.

To actually do it, you would need to create the images and then load them into the page...

Code: Select all
<script type="text/javascript">
var thumbWidth = 100; // Width for thumbnails

var image1 = new Image();

image1.src = 'this.jpg';

// write the larger image to the page

document.write('<img src="' + image1.src + '" width="' + image1.width + '" height="' + image1.height + '" />');

// Write the thumb

document.write('<img src="' + image1.src + '" width="' + (Math.round((thumbWidth/image1.width) * image1.width)) + '" height="' + (Math.round((thumbWidth/image1.width) * image1.height)) + '" />');


</script>

That should do it ^
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #4 (permalink)  
Old Jan 19th, 2008, 21:03
Junior Member
Join Date: Jan 2008
Location: Northern Ireland
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to make a thumbnail using javascript?

I mean like cropping them in a certain place?

Anyone?
Reply With Quote
  #5 (permalink)  
Old Jan 19th, 2008, 21:07
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,266
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: How to make a thumbnail using javascript?

Don't think so. That's beginning to get rather complex. I would suggest a PHP approach, but I'm not sure. Some links I found:
http://superaff.com/archives/2006/03...resize-script/
http://blazonry.com/scripting/upload-size.php
http://www.hotscripts.com/PHP/Script...ion/index.html
http://www.google.com/search?hl=en&r...esizer&spell=1
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #6 (permalink)  
Old Jan 20th, 2008, 09:50
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to make a thumbnail using javascript?

So what you're talking about isn't thumbnails at all then?

You want to clip a certain amount of the image away? If this is the case you can do it with CSS
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #7 (permalink)  
Old Jan 20th, 2008, 15:18
Junior Member
Join Date: Jan 2008
Location: Northern Ireland
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to make a thumbnail using javascript?

Quote:
Originally Posted by Rakuli View Post
So what you're talking about isn't thumbnails at all then?

You want to clip a certain amount of the image away? If this is the case you can do it with CSS
Yes, but in return they will come out as thumbnails.. you know what i mean? lol

Would you know how to do that in css?

Would you just put an image in a div and make the div size the size i want it to be clipped?
Reply With Quote
  #8 (permalink)  
Old Jan 21st, 2008, 01:58
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to make a thumbnail using javascript?

Use clipping like this

HTML: Select all
<div style="clip: rect(10px 10px 10px 10px);">
<img src="someimage.jpg" width="100" height="100" />
</div>
That will clip 10px off top right bottom and left of the contents of the div.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
A new simple way to make a image slider- Javascript Code o0DarkEvil0o JavaScript Forum 1 May 20th, 2008 01:37
HELP - IE7 Thumbnail Images on a tab ActionPart Web Page Design 2 Jul 15th, 2007 13:00
thumbnail and text next to each other konnor5092 Web Page Design 15 Jul 2nd, 2007 11:51
Scrolling thumbnail Dan Oliver Flash & Multimedia Forum 1 Jun 6th, 2007 16:22
How does one make thumbnail images? Picard Website Planning 3 Dec 29th, 2006 13:34


All times are GMT. The time now is 11:04.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43