Quote:
Originally Posted by SECTalk.com
Hey guys,
Seems like I've got it working really well now:
http://www.sectalk.com/boards/section/food-11/
For now, I'm trying to figure out how to get a image to center inside the frame when it is overly large. Right now, it aligns the top left corner of the frame with the image.
And I will definitely share my code. Hopefully I can put this in a product with all the settings inside the admin cp.
|
Most script and/or classes are counting from 0,0 (top left edge) to crop the image at a specific width. Some others, more sophisticated they're allowing to specify this top-left point on your own. But again is not so good. You most probably want to crop it having center the center of the image. You need to make some runtime calculations:
- Get the image's width eg 700px
- Subtrack the desired width eg 700-600 = 100
- Divide by 2 (100/2 = 50)
- Get the image's height eg 400 px
- Subtrack the desired height eg 400-350 = 50
- Divide by 2 (50/2 = 25)
After it the topleft position is: 25,50 (25px from top, 50px from left). With these settings you can get from an image 700X400, a new one 600X350 cropped centered.
By the way, my partner
Jeff Ledger is planing to release such a slider the upcoming week.
Maria