I get the error Undefined property: stdClass::$image
when uploading an image to a page template. The error handler specifically references line 722 in adminbasecontroller.php. The image specific blueprint is here:
header.image:
type: file
label: Screenshot
limit: 1
destination: 'self@'
multiple: false
style: vertical
accept:
- image/*
The image gets uploaded regardless of error, but the header is not updated...
Rolling back to 1.8.1 fixed it for now.
Don't do this, pagemedia field already uploads to the page folder. File field is intended to be used in other non-page blueprints.
So, what would the correct way be to achieve this, blueprint wise?
Same here. Since the update to Grav 1.4.5 and Admin 1.8.2, I cannot upload images, resulting in the same error @superDuperCyberTechno reported.
My blueprint excerpt is as follows:
[...]
header.images:
type: file
label: Images
random_name: true
multiple: true
limit: 2
destination: 'assets'
filesize: 10
accept:
- image/*
[...]
This has worked thus far without issue. The update broke it.
If there are breaking changes, it would be advantageous to know about them before the update. If there are best practices, it would be great to know about them at all instead of just getting a response like
Don't do this, pagemedia field already uploads to the page folder. File field is intended to be used in other non-page blueprints.
without any pointers as to why. I created the blueprint according to the documentation at the time and it worked. Either this is a bug or a breaking, non-documented change.
Update: Downgrading to Admin 1.8.1 resolved this for me as well. This reinforces my impression that this is most likely a bug introduced in 1.8.2.
Additionally, I have found out that when deleting one post with this setup, all images in the assets
folder get deleted. This appears to be a rather large bug in the admin interface inner workings and has caused me tons of frustration today.
We didn’t realize this was a breaking change because this field really is not intended to replace pagemedia picker. Now we have a couple of reports of people using file field in conjunction with pagemedia picker, we’ll investigate and find a solution. Sorry about this!
FYI the recommended approach is to use the standard pagemedia field to upload images into a page and a filepicker to select them for specific header variables
FYI the recommended approach is to use the standard pagemedia field to upload images into a page and a filepicker to select them for specific header variables
This recommended approach strikes me as counter-intuitive. Uploading and assigning a file/image to a field should be one action, not two. Teaching users to do it in two steps would be frustrating and should not be necessary.
In any case, thanks for looking into it.
Issue can be fixed by changing line 722 in adminbasecontroller.php to have isset()
:
if (isset($obj->header()->{$init_key})) {
This issue has been fixed in Admin 1.8.3
Most helpful comment
Issue can be fixed by changing line 722 in adminbasecontroller.php to have
isset()
: