Elements + Image Fields
Guys, I've set up an image type field in my config\decoy\elements.yaml file:
seo:
label: SEO
help: SEO and social integrations
sections:
general:
ogimage:
type: image
label: Open graph (fallback and home):
value: /img/og_logo.png
On the first save, the image was moved to public\uploads\emelents. Then... when the page refreshs, the file goes missing. Reload again, these 2 errors:
Exception in Element.php line 263: All Element images must be stored in public/img
and
ErrorException in Element.php line 263: All Element images must be stored in public/img (View: /home/vagrant/Code/mambo/vendor/bkwld/decoy/views/elements/index.haml)
I tried to find the issue myself, no success there. I think it's something in the getReplacementImage() at Elements.php, ln 238. It tests if the image has changed or something and deletes the old one. Maybe a false positive is making the code to delete the image around there.
I found and fixed an issue with Element default images when using the longhand syntax you're using there (like instead of ogimage,image: /img/og_logo.png. However, what I experienced manfiested differently than what you reported:
ErrorException in Element.php line 237: pathinfo() expects parameter 1 to be string, array given (View: /Users/reinhard/Work/Open Source/decoy/views/elements/index.haml)
I can no longer reproduce any errors using the /example app: http://yo.bkwld.com/2U1Z3c1R1L1G. I'm hoping e150ed7 somehow does fix it for you.
Can you tell me which what version or commit (from composer.lock) you are running?
dev-master
And what commit hash? Just wanna make sure I'm working using the same everything.
c7f7125
Here are the steps that leads to this error:
- Create a image field with any name and put a default value pointing to an existing file in the
public/imgfolder.
seo:
label: Tests
help: test
sections:
general:
test_image:
type: image
label: Test image
value: /img/test.png
- Open elements in admin. You will notice (for me happens this way) that the image field hasn't loaded the image.
- Save it... error.
@weotch were you able to reproduce the error?