hypejunction / images
Images API
Installs: 154
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 1
Type:elgg-plugin
Requires
- php: >=5.5
- composer/installers: ~1.0
- hypejunction/proxy: *
- imagine/imagine: ~0.6
README
Features
- Generic API for handling image files and entity avatars
- Standardized handling of thubmnails for all image files
API
elgg_imges_create_from_upload()
- create image file from uploadelgg_images_create_from_resource()
- create image file from a file resourceelgg_images_crop()
- crop source imageelgg_images_is_image()
- check if an entity is an imageelgg_images_create_thumbs()
- creates thumbnails for an imageelgg_images_get_thumbs()
- returns a thumbnail file objectelgg_images_clear_thumbs()
- removes all image thumbnailselgg_images_create_avatar_from_upload()
- create an avatar for an entity from file uploadelgg_images_create_avatar_from_resource()
- create an avatar for an entity from file resourceelgg_images_clear_avatars()
- clear entity avatarselgg_images_get_avatar()
- get avatar for an entity
Hooks
'thumb:sizes',$entity_type
- filters thumnail sizes configuration array'thumb:directory', $entity_type
- filters directory name in entity owners filestore directory where thumbs will be saved'thumb:filename', $entity_type
- filters filename that will be given to the thumbnail'options', 'imagine'
- filters options passed to Imagine, when saving cropped images
Thumbs config
Thubm sizes can be configured as an array of options:
// Add `media` size that will be cropped in an `outbound` mode filling a 640x360 container. $thumbs['media'] = [ 'w' => 640, // max width 'h' => 360, // max height 'square' => false, // crop a square 'croppable' => true, // allow cropping 'mode' => 'outbound', // 'inset' or 'outbound' ];
By default, all square thumbs will be cropped in outbound
mode.
master
size will be crooped in inset
mode without cropping.
Notes
-
This plugin distinguishes between thumbs and avatars. Thumbs are resized instances of the ElggFile entity, whereas avatars are ElggFile entities contained by the entity they belong to. Avatars belong to non file entities and have thumbs.
-
If you override file plugin thumbs, you will need to update the file upload action to remove the code that generates thumbnails. Otherwise, two sets of thumbs will be generated. Currently there is no way to non-intrusively override thumb generation in the file plugin.