Media module: Error on insert media



  • Hi,

    I get a JS error when I try to link a media file to a entity of a self created Module. When I click the button 'Voeg dit bestand in' the popup reloads and generate the JS error.

    Media error on insert

    Files are uploaded successfully and also the thumbnails are generated.

    The issue occurs on a Ubuntu 16.x preview server.
    AsgardCMS is installed as new project on the server and git pull to get full project.
    Of course on development environment this is working like a charm!

    Witch other information can I provide to solve this issue?

    Best regards,
    StanB


  • admin

    Hello,

    Please specify the full error you're having. You're showing the translation file from datatables instead of the error.

    Please also specify which version of the media module you're using.

    Thank you.



  • do you have the latest version of the Media module ?


  • admin

    If this is not happening on local double check that your permissions are set correctly.



  • Hi,

    Media module version is 1.25.3
    On development env version is 1.25.1 (working just fine)
    After updating media module (on dev env) to 1.25.4 (just released?)
    I get an JS error as well, different than on preview server:

    (index line 522, kol 16 of path 'backend/media/media-grid/index')
    TypeError: window.opener.includeMediaMultiple is not a function
    window.opener.includeMediaMultiple(mediaId, filePath);

    I downgraded the media module back to 1.25.1 but this is not working any more. I get the same error as on v. 1.25.4

    The only error is the JS error I get and no error in laravel.log file.
    Permissions on the files are OK, since I'm able to upload, modify and delete the media files.

    Best regards,
    StanB



  • Caching issue this one:

    index line 522, kol 16 of path 'backend/media/media-grid/index')
    TypeError: window.opener.includeMediaMultiple is not a function
    window.opener.includeMediaMultiple(mediaId, filePath);

    Make sure you have cleared your view



  • Unfortunately it is not cache, I tried in three different browsers, all cache cleared.

    The error says that includeMediMultiple is not a function, it is on a media::admin.fields.new-file-link-single field. Could this be a clue?


  • Global Moderator

    @StanB Very interesting single partial does not even have includeMediMultiple word in it.

    Did you clear browser cache?
    Just clarifying to clear laravel view cache (php artisan view:clear).



  • thanks @armababy I was indeed speaking about the laravel cache



  • Laravel cache is also completely cleared. Removed all cache files in the following folders:
    storage/framework/cache
    storage/framework/sessions
    storage/framework/views

    Still get the js error. I'm back on Media Module version 1.25.4


  • Global Moderator

    Anyone can replicate this?

    I tried on Opera, Firefox, Chrome everything works for me without errors on Media 1.25.4



  • Can't replicate it neither, only tried with FF and Chrome



  • I tried on a freshly installed version and the error is gone.
    I still hope someone has an idea how the problem could occur since I don't want the same issue again. It is time wasting to have to restart on a fresh install after an update.



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


Log in to reply
 

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