- Online Demo 1
- Local Downloads
Everyone in the Web site development and Web applications often need to deal with pictures, because the user upload images are often different size, how to generate a uniform size of the thumbnail is often a headache, the general way is basically using the background program php,jsp and other processing after uploading the image, Cut thumbnails of the specified size for Web sites or application specific needs. The main problem is that you need to develop the corresponding background related programs, and once you specify the thumbnail size, later if you want to be able to modify at any time, often need to modify the background code, very troublesome! Today we will introduce an ultra-strong jquery thumbnail Generation plugin-nailthumb, use this plugin can help you in the foreground to generate no image distortion thumbnail, and support the foreground clipping, add picture description and animation functions, I believe you will love!
Key Features
- Auto-processing of graphics rate, no distorted picture generated
- Ability to add thumbnail effects
- Support cropping
- Easy to add picture description
How to use
Import jquery class library, plugin JS and CSS, as follows:
- <link rel="stylesheet" href="Css/jquery.nailthumb.1.0.min.css">
- <script src="Http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"> </script>
- <script src="Js/jquery.nailthumb.1.0.min.js"></script>
Call the plug-in method, as follows:
- $('. Thumbwrapper '). Nailthumb({});
Use the container element of the picture to generate a thumbnail image.
Image thumbnail display app
Here we will develop an image thumbnail display application, the main code is as follows:
Html
- <ul id="container">
- <li data-tag = "Ducati" ><strong>hypermotard 796 Silver</strong> src=< Span class= "ATV" > "img/motor/model-page_2012_hypermotard_796_298.jpg" ><a href= "#" Class= "viewthumb" >view thumbnails< span class= "tag" ></A></LI>
- <li data-tag = "Ducati" ><strong>hypermotard 796 Red</strong> src= "img/motor/hm-796_2001_r_[298x168].jpg" ><ahref= "#" class= "viewthumb" >view Thumbnails </A></LI>
- <li data-tag="Ducati"><strong>hypermotard 1100 Evo Red</strong> src="Img/motor/2012-ducati-hypermotard-1100evo4-298.jpg"> <a href="#" class="Viewthumb">View Thumbnails</a> </li>
- </ul>
- <ul id="thumb">
- <li class = "Thumbwrapper Bhoriz" > <a href= "#" > src= "img/ Motor.png " title=" 280x180 " /></A></LI>
- <li class = "Thumbwrapper bsquare" > <a href= "#" > src= "img/ Motor.png " title=" 150x150 " /></A></LI>
- <li class = "Thumbwrapper Vert" ><a href= "#" > Span class= "ATN" >src= "img/motor.png" = "100x130" /></a></li
- <li class = "Thumbwrapper Square" ><a href= "#" > src= "img/motor.png" title< Span class= "pun" >= "100x100" /></a></li>
- <li class="Thumbwrapper horiz"><a href="#"> src="Img/motor.png" title="100x70" /></a></li>
- </ul>
Define two container elements, one containing a picture of the thumbnail to be generated, and another containing a different size thumbnail for the resulting image. Javascript
- $(function() {
- $('. Viewthumb '). Click(function() {
- var location = $(this). Parent(). Find(' img '). attr(' src ');
- var title = $ (this Parent (). Find "strong"
- $('. Thumbwrapper '). Nailthumb({imageUrl:location, imagefromwrappinglink:true, title :title, titlewhen: ' Load ', replaceanimation:' animate ' });
- });
- $('. Thumbwrapper '). Nailthumb({});
- });
In the above code we use the default option to generate thumbnails for the default picture, and then click to generate thumbnails of the various sizes of the specified picture.
Css
Here we pre-define thumbnails of different sizes, as follows:
- . Bhoriz {
- Width: 280px;
- Height: 180px;
- }
- . Square {
- Width: 100px;
- Height: 100px;
- }
- . bsquare {
- Width: 150px;
- Height: 150px;
- }
- . Horiz {
- Width: 100px;
- Height: 70px;
- }
- . Vert {
- Width: 100px;
- Height: 130px;
- }
Please refer to the online demo for results. I hope you like this plugin, can be effectively applied to the Web site and Web application development. If you like our article, please leave us a message. Thank you! Original link: http://www.gbtags.com/gb/share/5860.htm
Create a beautiful thumbnail web app using the awesome jquery thumbnail build plugin nailthumb