aerni / statamic-imagekit

This Statamic addon provides an easy way to generate ImageKit URLs
https://statamic.com/addons/aerni/imagekit
MIT License
1 stars 0 forks source link

Transforming an DigitalOcean Spaces image returns ErrorException #3

Open shoored opened 3 years ago

shoored commented 3 years ago

First of all, thank you for this great add-on.

I have an assets container in Statamic that uses DigitalOcean Spaces as the filesystem. Statamic can upload images, I can select them in the asset field and output the image with regular img-tags and Antler variables on the front-end.

My ImageKit account has a new External storage pointing to the DigitalOcean Spaces bucket. I have also created a new endpoint.

Manually creating an ImageKit URL with one of the images on the DO Spaces bucket works okay.

When I try to transform an image with the addon I get the following error

ErrorException
Undefined offset: 1

Examples:

Env vars

IMAGEKIT_DOMAIN=ik.imagekit.io
IMAGEKIT_ID=syntax
IMAGEKIT_IDENTIFIER=ohdeer
IMAGEKIT_BYPASS=false

Data I have one page in my Statamic setup with this content:

---
id: home
blueprint: pages
title: Home
template: home
singleimage: photo_2021-06-23-11.58.58.jpeg
---

The singleimage is an Asset field which uses the DO Spaces filesystem.

Front-end code Neither of these methods seem to work

{{ imagekit :src="singleimage" w="100" bl="15" q="100" }}
{{ imagekit :src="singleimage:path" w="100" bl="15" q="100" }}
{{ imagekit :src="singleimage:url" w="100" bl="15" q="100" }}

I have also put the site on a staging server where the same error occurs.

aerni commented 3 years ago

Can you please post the Stack Trace of the error. You should find it in storage/logs/laravel.log.

shoored commented 3 years ago

I tried a different syntax after a tip in Discord, this does seem to work! :

{{ singleimage }}
    {{ imagekit:path w="100" bl="15" q="100" }}
{{ /singleimage }}

I cannot get the Single image example from the docs working. It that simply because of the external DO asset?

Here's the stack trace:


[previous exception] [object] (ErrorException(code: 0): Undefined offset: 1 at /Users/sjoerd/dev/ohdeer/vendor/statamic/cms/src/Assets/AssetRepository.php:80)
[stacktrace]
#0 /Users/sjoerd/dev/ohdeer/vendor/statamic/cms/src/Assets/AssetRepository.php(80): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined offse...', '/Users/sjoerd/d...', 80, Array)
#1 /Users/sjoerd/dev/ohdeer/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(261): Statamic\\Assets\\AssetRepository->findById('home')
#2 /Users/sjoerd/dev/ohdeer/vendor/aerni/imagekit/src/ImagekitTags.php(166): Illuminate\\Support\\Facades\\Facade::__callStatic('findById', Array)
#3 /Users/sjoerd/dev/ohdeer/vendor/aerni/imagekit/src/ImagekitTags.php(127): Aerni\\Imagekit\\ImagekitTags->asset()
#4 /Users/sjoerd/dev/ohdeer/vendor/aerni/imagekit/src/ImagekitTags.php(258): Aerni\\Imagekit\\ImagekitTags->focus()
#5 /Users/sjoerd/dev/ohdeer/vendor/aerni/imagekit/src/ImagekitTags.php(317): Aerni\\Imagekit\\ImagekitTags->getImagekitParams()
#6 /Users/sjoerd/dev/ohdeer/vendor/aerni/imagekit/src/ImagekitTags.php(185): Aerni\\Imagekit\\ImagekitTags->buildImagekitTransformation()
#7 /Users/sjoerd/dev/ohdeer/vendor/aerni/imagekit/src/ImagekitTags.php(85): Aerni\\Imagekit\\ImagekitTags->buildUrl('photo_2021-06-2...')
#8 [internal function]: Aerni\\Imagekit\\ImagekitTags->index()
#9 /Users/sjoerd/dev/ohdeer/vendor/statamic/cms/src/View/Antlers/Engine.php(158): call_user_func(Array)
#10 [internal function]: Statamic\\View\\Antlers\\Engine::renderTag(Object(Statamic\\View\\Antlers\\Parser), 'imagekit', Array, '', Array)
#11 /Users/sjoerd/dev/ohdeer/vendor/statamic/cms/src/View/Antlers/Parser.php(578): call_user_func_array(Array, Array)
#12 /Users/sjoerd/dev/ohdeer/vendor/statamic/cms/src/View/Antlers/Parser.php(177): Statamic\\View\\Antlers\\Parser->parseCallbackTags('<div class=\"pb-...', Array)

Sorry it seems to be such a silly syntax thing. I really appreciate the time you put into this addon and feedback.

aerni commented 3 years ago

Great you got it working. I will investigate the issue of why the other syntax didn't work. But for now, just use the syntax that works.