File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626 */
2727class CloudinaryImageService extends AbstractCloudinaryMediaService
2828{
29-
3029 /**
3130 * @var ExplicitDataCacheRepository
3231 */
@@ -37,6 +36,13 @@ class CloudinaryImageService extends AbstractCloudinaryMediaService
3736 */
3837 protected $ storageRepository ;
3938
39+ protected array $ defaultOptions = [
40+ 'type ' => 'upload ' ,
41+ 'resource_type ' => 'image ' ,
42+ 'fetch_format ' => 'auto ' ,
43+ 'quality ' => 'auto ' ,
44+ ];
45+
4046 /**
4147 *
4248 */
@@ -154,6 +160,16 @@ public function max($items) {
154160 return max ($ items );
155161 }
156162
163+ public function getImageUrl (File $ file , array $ options = []): string
164+ {
165+ $ options = array_merge ($ this ->defaultOptions , $ options );
166+
167+ $ publicId = $ this ->getPublicIdForFile ($ file );
168+
169+ $ this ->initializeApi ($ file ->getStorage ());
170+ return \Cloudinary::cloudinary_url ($ publicId , $ options );
171+ }
172+
157173 /**
158174 * @param array $breakpoints
159175 *
You can’t perform that action at this time.
0 commit comments