Media module: Error on insert media
Got the same error again after importing my own created modules. In other words I have to find a solution to fix this.
A console.log on window.opener.single = undefined
window.opener does exist
I found out that it is only in the edit form and not on a create form.
I use the following code in the edit form:
@include('media::admin.fields.file-link', [ 'entityClass' => 'Modules\\\\Brand\\\\Entities\\\\Brand', 'entityId' => $brand->id, 'zone' => 'logo' ]) @include('media::admin.fields.file-link', [ 'entityClass' => 'Modules\\\\Brand\\\\Entities\\\\Brand', 'entityId' => $brand->id, 'zone' => 'header' ])
In the controller:
public function edit(Brand $brand)
$header = $brand->getHeaderImage();
$logo = $brand->getLogo();
$pages = $this->getPagesForSelect();
return view('brand::admin.brands.edit', compact('brand', 'header', 'logo', 'pages'));
Did you try using new partials and whole process? Or that is not an option for you?
How do you use old partials on create forms?
At least we can now see problem, new implementation of recent fix needs to be back ported also.
@motchju will you PR new changes to old partial fields or should i do it?
@armababy not sure if I understand you completely.
I'm using the partial from the docs in the edit section.
'entityClass' => 'Modules\\\\Article\\\\Entities\\\\Article',
'entityId' => $article->id,
'zone' => 'coverimage'
The partials on the create page are from the create section:
@include('media::admin.fields.new-file-link-single', [ 'zone' => 'logo' ]) @include('media::admin.fields.new-file-link-single', [ 'zone' => 'header' ])
If you can you should change all partials to new
media::admin.fields.new-file-link-singleones like you have in create view.
Currently we forgot to back port new changes to old partials
If updating to new ones and use events is not for you, we wait for PR.
Documentation on edit view is a bit outdated on new method currently.
Basically you can use new partials in all your views and make 1 or 2 events that implements StoringMedia. You can use 1 event if no differences in code.
Ok, the new partial is also not really the solution, I'm able now to select an image, but it is not stored in the imageables table.
I hope that the back port will be available soon and the documentation will be updated as well.
@StanB Did you fire event on update method?
hmm, probably not.... I will check and fix it soon. I will let you know if it fixed it.
@StanB I'm currently using new partials on all views with 1 event.
Only thing is that it currently does not remove already attached media files, also does not update orders of multiple form.
Issue raised @github#214
it can detach items too as it is explained in the docs.
There is also no need to fire an event on update as that is not used.
I am able to reproduce the error on edit views indeed.
@motchju must have forgotten about those while doing he PR
I've applied changes from @motchju from here to the
file-link-multiplepartials . But in general.blade.php
window.opener.singleis still undefined, I'm not sure where @motchju you set that ?
we have discuss via slack, a new version that will fixed this behavior will arrive soon
This has been fixed now on version 1.25.5.
Please test and confirm
Thank you, version 1.25.5 is working correctly. Also on the preview environment.
Thanks for the support!