This package currently ships with 4 rendering
services, Glide, Imgix, Twicpics, and a local minimalistic rendering service. It is very simple to implement another one like Cloudinary or even another local service like or Croppa.
Changing the image rendering service can be done by changing the MEDIA_LIBRARY_IMAGE_SERVICE
environment variable to one of the following options:
A17\Twill\Services\MediaLibrary\Glide
A17\Twill\Services\MediaLibrary\Imgix
A17\Twill\Services\MediaLibrary\TwicPics
A17\Twill\Services\MediaLibrary\Local
For a custom image service you would have to implement the ImageServiceInterface
and modify your twill
configuration value media_library.image_service
with your implementation class.
Here are the methods you would have to implement:
1<?php 2 3public function getUrl($id, array $params = []); 4public function getUrlWithCrop($id, array $crop_params, array $params = []); 5public function getUrlWithFocalCrop($id, array $cropParams, $width, $height, array $params = []); 6public function getLQIPUrl($id, array $params = []); 7public function getSocialUrl($id, array $params = []); 8public function getCmsUrl($id, array $params = []); 9public function getRawUrl($id);10public function getDimensions($id);11public function getSocialFallbackUrl();12public function getTransparentFallbackUrl();
$crop_params will be an array with the following keys: crop_x, crop_y, crop_w and crop_h. If the service you are implementing doesn't support focal point cropping, you can call the getUrlWithCrop from your implementation.