CodeSleeve / stapler

ORM-based file upload package for php.
http://codesleeve.com
Other
538 stars 144 forks source link

Store dimensions of image #165

Open flyingL123 opened 8 years ago

flyingL123 commented 8 years ago

It would be great if there was a way to store the actual dimensions of each image style in the database. Maybe we can add a column called {attachment_name}_dimensions, and save a serialized array representing the physical sizes for each style, for example:

['zoom' => ['width' => 1280, 'height' => 1000], 'thumbnail' => ['width' => 100, 'height' => 63]]

The image dimensions are required to use the great photoswipe.js library. I managed to implement this myself in a project using a very less-than-ideal workaround involving a direct database right of the dimensions inside the closure defining the style. I was unable to find a better way since there are no events that fire during the image processing process, which means there was no way to hook into it and store the dimensions.

It would be really great to have the library store these dimensions automatically by default.