hypejunction / hypeicons
Interface for uploading and cropping entity icons and covers
Installs: 36
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 1
Type:elgg-plugin
Requires
- php: >=5.5
- bower-asset/cropper: ~2.1
- composer/installers: ~1.0
This package is auto-updated.
Last update: 2020-01-29 04:04:31 UTC
README
Interface for uploading and cropping entity icons and covers
Features
- Generic API for uploading, handling and cropping entity icons and covers
- Admin settings to enable icons/covers for all entity types
- Allows to crop file thumbnails
- Allows to crop user and group avatars and cover images
- An option switch between square, rounded and circle entity icons
- An option to replace default entity icons with SVG
- An option to replace default filetype icons with SVG
- Responsive icon/cover cropping
Screenshots
Notes
Default entity type icons
To replace a default entity icon/cover, simply place an image in views/default/<icon_type>/<entity_type>/<entity_subtype>.<ext>
, where:
ext
is eithersvg
,png
,gif
orjpg
.icon_type
is eithercover
oricon
Add a cropper as a form input
// in your form echo elgg_view('input/cropper', array( 'src' => 'http://example.com/uri/image.jpg', 'ratio' => 16/9, 'name' => 'crop_coords', )); // in your action $coords = get_input('crop_coords');
Add cropper to a file input
This will allow users to crop an image before uploading it to the server.
// in your form echo elgg_view('input/file', array( 'name' => 'avatar', 'use_cropper' => true, )); // in your action $coords = get_input('crop_coords');
You can as well pass preset coordinates and images source.
// in your form echo elgg_view('input/file', array( 'name' => 'cover', 'use_cropper' => array( 'name' => 'cover_crop_coords', 'ratio' => 16/9, 'src' => '/uri/image.jpg', // previously uploaded file 'x1' => 100, 'y1' => 100, 'x2' => 260, 'y2' => 190, ), )); // in your action $coords = get_input('cover_crop_coords');
In your action, be sure to use the same image source for cropping. If you passed master image source to the file input, you will need to implement the logic for both new file upload and master image, as cropping coordinates may change even without new file upload.
Displaying a cover image
echo elgg_view('output/cover', [ 'entity' => $entity, ]);
Adding cover image in layout header
echo elgg_view_layout('one_sidebar', [ 'entity' => $entity, 'show_cover' => true, 'title' => 'Page with cover', 'content' => 'Page content', ]);