Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elements + Image Fields #45

Open
SomosAMambo opened this issue Apr 26, 2017 · 7 comments
Open

Elements + Image Fields #45

SomosAMambo opened this issue Apr 26, 2017 · 7 comments
Labels

Comments

@SomosAMambo
Copy link

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.

@weotch
Copy link
Member

weotch commented Apr 27, 2017

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 weotch closed this as completed Apr 27, 2017
@SomosAMambo
Copy link
Author

screencap.mov.zip

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

@weotch weotch reopened this May 1, 2017
@weotch weotch added the bug label May 1, 2017
@weotch
Copy link
Member

weotch commented May 1, 2017

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

@SomosAMambo
Copy link
Author

dev-master

@weotch
Copy link
Member

weotch commented May 1, 2017

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

@SomosAMambo
Copy link
Author

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
Copy link
Author

@weotch were you able to reproduce the error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants