You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Elefant needs more elegant image processing and storage. Currently, this is up to the implementor and is handled with the Image::resize() method, often as a template filter. This requires that the original file be left in place, to compare the timestamps and regenerate the thumbnail as needed.
A better solution should integrate with the models themselves, similarly to how Paperclip does with ActiveRecord and Rails.
Building on the $fields property, which is currently used for model relationships, an image might be defined like this:
<?phpclassMemberextendsModel {
public$fields = array (
'avatar' => array (
'is_a' => 'Image',
'styles' => array (
'default' => array (300, 300, 'stretch', 'png'),
'thumb' => array (120, 120)
),
'keep_original' => false,
'default' => '/files/default_avatar.png'
)
);
}
$m = newMember (123);
// handle an uploaded file$m->avatar ($_FILES['avatar']);
// ensure the image id is saved$m->put ();
// get the file id and urlsecho$m->avatar; // -> 456echo$m->avatar (); // -> '/cache/thumbs/678c...ac52-stretch-300x300.png'echo$m->avatar ('thumb'); // -> '/cache/thumbs/678c...ac52-cover-120x120.jpg'?>
The Image class would be expected to provide an interface to Model that would handle the image correctly based on the settings in the $fields array, storing only an ID for that image in the field itself.
Behind the scenes, the Image class would store the image info in a simple table like this:
create table #prefix#image (
id integerprimary key,
added datetime not null,
status intnot null,
styles textnot null
);
The status could be used to queue images for transfer to S3 or another external storage service. 0 could be unprocessed, 1 could be resizing, 2 could be transferring, and 3 could be processed.
The styles would be a JSON encoded object with links to the local or remote URL of an image for each style, for example:
Depending on the settings, image resizing and transfer would be moved out of the current request and into a script that would run from the command line. The Image class is already part of the filemanager app, and since this pertains to file management, it makes sense for these settings to go in the filemanager's config. Settings might include:
s3 credentials
resize_in_queue = On|Off
transfer_in_queue = On|Off
tbd...
The new $fields relationship is_a could also be used to define other types of processors such as Video down the road.
The text was updated successfully, but these errors were encountered:
Elefant needs more elegant image processing and storage. Currently, this is up to the implementor and is handled with the
Image::resize()
method, often as a template filter. This requires that the original file be left in place, to compare the timestamps and regenerate the thumbnail as needed.A better solution should integrate with the models themselves, similarly to how Paperclip does with ActiveRecord and Rails.
Building on the
$fields
property, which is currently used for model relationships, an image might be defined like this:The
Image
class would be expected to provide an interface toModel
that would handle the image correctly based on the settings in the$fields
array, storing only an ID for that image in the field itself.Behind the scenes, the
Image
class would store the image info in a simple table like this:The status could be used to queue images for transfer to S3 or another external storage service. 0 could be unprocessed, 1 could be resizing, 2 could be transferring, and 3 could be processed.
The styles would be a JSON encoded object with links to the local or remote URL of an image for each style, for example:
Image
could even be anExtendedModel
withstyles
as the extended field. With caching, this could be a fast solution for image lookups.Depending on the settings, image resizing and transfer would be moved out of the current request and into a script that would run from the command line. The
Image
class is already part of the filemanager app, and since this pertains to file management, it makes sense for these settings to go in the filemanager's config. Settings might include:The new
$fields
relationshipis_a
could also be used to define other types of processors such asVideo
down the road.The text was updated successfully, but these errors were encountered: