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'));
    }

    Any suggestions?


  • Global Moderator

    @StanB

    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.

    Edit views

    @include('media::admin.fields.file-link', [
    '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'
    ])

  • Global Moderator

    @StanB

    If you can you should change all partials to new media::admin.fields.new-file-link-single ones like you have in create view.
    Currently we forgot to back port new changes to old partials media::admin.fields.file-link.
    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.


  • Global Moderator

    @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.


  • Global Moderator

    @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


  • admin

    it can detach items too as it is explained in the docs.


  • admin

    There is also no need to fire an event on update as that is not used.


  • admin

    I am able to reproduce the error on edit views indeed.

    @motchju must have forgotten about those while doing he PR


  • admin

    I've applied changes from @motchju from here to the file-link and file-link-multiple partials . But in general.blade.php window.opener.single is 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


  • admin

    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!


  • admin

    Awesome!


Log in to reply
 

Looks like your connection to AsgardCms was lost, please wait while we try to reconnect.