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

Admin v1.10.0-rc.8 – Media upload: onAdminAfterAddMedia? #1867

Closed
clivebeckett opened this issue Apr 10, 2020 · 5 comments
Closed

Admin v1.10.0-rc.8 – Media upload: onAdminAfterAddMedia? #1867

clivebeckett opened this issue Apr 10, 2020 · 5 comments
Assignees

Comments

@clivebeckett
Copy link

My Admin Addon Media Metadata Plugin is making use of the event hook onAdminAfterAddMedia to create a [mediafile].meta.yaml file for each newly uploaded media file with empty values for title, alt, and caption.

In Admin v1.10.0-rc.8 that doesn’t work anymore since files are being stored in a tmp folder and moved to the page folder only on saving the page.

  1. Is the event hook onAdminAfterAddMedia still being fired? If not, what’s the alternative?
  2. What is the reason for the temporary storage? First I thought this is to make uploading possible for new pages – but you still have to save a new page once, before being able to upload media files.

See also the issue Limited functionality in Admin Plugin v1.10.0-rc.8 in my plugin’s repository: clivebeckett/grav-plugin-admin-addon-media-metadata#7

@mahagr
Copy link
Member

mahagr commented Apr 23, 2020

Regarding to why temporary location is being used:

Using temporary files before saving has multiple benefits, including that you can upload files on new pages and that your pages won't be broken while you are modifying them. This means that frontend will not change until you hit save.

This also means that all the media will be added/removed at once during the save.

I need to check if onAdminAfterAddMedia is still being called.

@clivebeckett
Copy link
Author

Using temporary files before saving has multiple benefits, including that you can upload files on new pages and that your pages won't be broken while you are modifying them. This means that frontend will not change until you hit save.

Thank you! So I wasn’t completely wrong about this being a feature to make upload for new pages available – only it isn’t yet working but probably in the final release. The other reason – not breaking pages while still editing them – also makes sense, I guess :)

So I’m excited to see how I can make my plugin work properly again.

@mahagr mahagr added the bug label Apr 27, 2020
@mahagr
Copy link
Member

mahagr commented Jun 26, 2020

@clivebeckett

I've now reverted the behavior of the pagemedia field to act just as it used to be in Grav 1.6. This is because of it is too large behavioral change and breaks multiple things. I have also fixed a few issues in file/image fields, so they should be used instead of pagemedia as they work also when creating a new page/object.

We may need to figure out how to add more metadata to the updated files, I think it should happen when you're uploading the file...?

@clivebeckett
Copy link
Author

I've now reverted the behavior of the pagemedia field to act just as it used to be in Grav 1.6. This is because of it is too large behavioral change and breaks multiple things.

Thanks, that sounds like good news to me :)

I have also fixed a few issues in file/image fields, so they should be used instead of pagemedia as they work also when creating a new page/object.

I don’t quite know what that means. But I’ll check once the next release is out.

We may need to figure out how to add more metadata to the updated files, I think it should happen when you're uploading the file...?

I’m not sure here either what you mean, I’m sorry. My plugin now creates the metadata file when you save data for the first time using the provided modal. Later on, the metadata will be overwritten by saving the form. There’s no creating an empty metadata file anymore, also because this got in the way with the automated EXIF data writing as provided by the core (setting media.auto_metadata_exif).

@mahagr mahagr added the fixed label Jul 1, 2020
@mahagr
Copy link
Member

mahagr commented Jul 1, 2020

Let's try out if everything works with this fix. If there are more issues, please just create a new issue about it.

@mahagr mahagr closed this as completed Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants