decoy icon indicating copy to clipboard operation
decoy copied to clipboard

Elements + Image Fields

Open SomosAMambo opened this issue 9 years ago • 7 comments

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.

SomosAMambo avatar Apr 26 '17 21:04 SomosAMambo

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.

weotch avatar Apr 27 '17 03:04 weotch

screencap.mov.zip

...Still the same. When I left the value empty, there is no error.

SomosAMambo avatar Apr 27 '17 14:04 SomosAMambo

Can you tell me which what version or commit (from composer.lock) you are running?

weotch avatar May 01 '17 16:05 weotch

dev-master

SomosAMambo avatar May 01 '17 16:05 SomosAMambo

And what commit hash? Just wanna make sure I'm working using the same everything.

weotch avatar May 01 '17 16:05 weotch

c7f7125

Here are the steps that leads to this error:

  1. Create a image field with any name and put a default value pointing to an existing file in the public/img folder.
seo:
  label: Tests
  help: test
  sections:
    general:
      test_image:
        type: image
        label: Test image
        value: /img/test.png
  1. Open elements in admin. You will notice (for me happens this way) that the image field hasn't loaded the image.
  2. Save it... error.

SomosAMambo avatar May 02 '17 12:05 SomosAMambo

@weotch were you able to reproduce the error?

SomosAMambo avatar May 09 '17 14:05 SomosAMambo