How?
In order to get the process of clipping images automated, some parameters are necessary to get the job done. These parameters are: size of original image, clipping offset and clipped size. I have chosen to use attributes on the img tag, allowing setting these values during design of the page.
Example
<img src="castle.jpg" id="clipit" alt="Clipped castle image"
width="300" height="225"
clipwidth="136" clipheight="105"
clipleft="82" cliptop="50"/>
As you can see, I have used some custom properties to the img tag, which will be used by javascript during the clipping process. In order to get the image clipped I have written a javascript function which can be called.
clipImage( 'id-of-image', 1);
This function will take care of it all and it will render the clipped image with the given parameters. I didnt spend much time on the code and it is quick and dirty. Maybe it would be an idea create a jQuery plugin for it.
Demo
The demo page showing the image clipping can be found here. Please look at the source to see the implementation.
Feedback/Comments
If you have any questions or remarks about this code, you
can always contact me at: ......
Links related to this entry: Clip image using css | jQuery page | CSS clip property
I am not, under any circumstances, responsible for any damaged occured during or after reading this website. Please contact me at: ...... © 2006 Oguz Karadeniz. Rights could be reserved.