Conflicting Files NPM Resource Changed ? Pending

User tests: Successful: Unsuccessful:

avatar brianteeman
brianteeman
2 May 2021

redo of #33090

#31048 added support for webp images however it was not complete. MediaHelper::isImage was not updated to support webp. As a result while webp could be added to media manager as an allowed image format everything worked except for the display of the thumbnail.

As this PR fixes that we might as well add webp to the default list of supported image formats.

To test

  1. either do a fresh install with the prebuilt package OR apply this pr, run npm ci and go to the media manager options. delete all the values in the Legal Extensions (File Types), Legal Image Extensions (File Types) and Legal MIME Types and then save the options. This will reset the value to the new defaults.
  2. Try to upload any webp image
  3. Try to crop and resize the image
  4. Try to rename the image
  5. Get a shareable link and make sure it works

Before

image

After

image

adc9a59 2 May 2021 avatar brianteeman v3
avatar brianteeman brianteeman - open - 2 May 2021
avatar brianteeman brianteeman - change - 2 May 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 2 May 2021
Category Administration com_media NPM Change Repository SQL Installation Postgresql Libraries
avatar richard67
richard67 - comment - 2 May 2021

@brianteeman Could you update the branch of this PR to latest 4.0-dev of upstream so we get rid of the unrelated javascript-cs errors in drone? Alternatively let me know if I shall do that for you. Thanks in advance.

avatar brianteeman brianteeman - change - 2 May 2021
Labels Added: NPM Resource Changed ?
avatar joomla-cms-bot joomla-cms-bot - change - 2 May 2021
Category Administration com_media NPM Change Repository SQL Installation Postgresql Libraries Administration com_media NPM Change JavaScript Repository SQL Installation Postgresql Libraries
avatar brianteeman
brianteeman - comment - 2 May 2021

done

avatar joomla-cms-bot joomla-cms-bot - change - 4 May 2021
Category Administration com_media NPM Change Repository SQL Installation Postgresql Libraries JavaScript Administration com_media NPM Change Repository SQL Installation Postgresql Libraries
avatar Quy
Quy - comment - 7 May 2021

I get the following error with crop/resize:

33481

avatar brianteeman
brianteeman - comment - 7 May 2021

@Quy I can not replicate that
before

avatar Quy
Quy - comment - 7 May 2021

Open browser's console.
Resize/crop.
Click Save button.
See console.

avatar brianteeman
brianteeman - comment - 7 May 2021

I understand what you said but I cannot replicate it

image

image

avatar Quy
Quy - comment - 7 May 2021

It must be my local setup then. I will try again on a hosting site. Thanks.

avatar Quy
Quy - comment - 7 May 2021

Same issue on cloudaccess.host. Hopefully, someone can test and confirm.

avatar brianteeman
brianteeman - comment - 21 May 2021

can anyone else replicate the issue @Quy reported

avatar jwaisner
jwaisner - comment - 23 May 2021

@brianteeman , I was able to replicate what @Quy experiences

image

This issue occurs though regardless of the patch. Seems like something else is going on.

image

avatar Quy
Quy - comment - 24 May 2021

Please fix conflicts so I can retest to see I can reproduce the issue. Thanks.

avatar Quy
Quy - comment - 24 May 2021

Here is the json response after saving the resized/cropped webp image. I don't know media manager to see how it handles the saved file.

{"success":false,"message":"Unable to upload file.","messages":{"error":["Illegal mime type detected: application/octet-stream"]},"data":null}

avatar brianteeman
brianteeman - comment - 25 May 2021

can you please confirm the settings in com_media options

avatar richard67
richard67 - comment - 25 May 2021

@brianteeman The problem seems to be the MIME type. @Quy 's JSON response shows Illegal mime type detected: application/octet-stream. Your PR adds "image/webp" to the default value for the field "Allowed MIME types" (or so), but it doesn't add "application/octet-stream". I'm not sure if that MIME type should be added because I have no idea what else uses that and if it can be dangerous.

@Quy Can you check if it works after you've added "application/octet-stream" to the allowed MIME types in media manager config?

avatar brianteeman
brianteeman - comment - 25 May 2021

it shouldnt add application/octet-stream.

avatar brianteeman
brianteeman - comment - 25 May 2021

I think I know the cause - just checking

avatar richard67
richard67 - comment - 25 May 2021

Possibly we need to update some library used for MIME type detection because it doesn't know webp yet?

avatar brianteeman
brianteeman - comment - 25 May 2021

no - thats not it - please wait

avatar brianteeman
brianteeman - comment - 25 May 2021

So the problem sounds the same as the issue with pdf files back with a change in 3.7
Can you confirm if fileinfo is enabled in php
Can you change this setting and see if it works
image

avatar Quy
Quy - comment - 25 May 2021

Can you confirm if fileinfo is enabled in php

Enabled.

Can you change this setting and see if it works

PHP Notice: exif_imagetype(): Read error! in \libraries\src\Helper\MediaHelper.php on line 74

The saved file no longer has the image/webp MIME type.

Folder
    local-images:/
Type
    File
Date Created
    2021-05-25 15:32
Date Modified
    2021-05-25 15:32
Dimensions
    - 
Size
    287.95 KB 
MIME Type
    application/octet-stream
Extension
    webp
avatar Quy
Quy - comment - 8 Jun 2021

Works in Chrome v91.0.4472.7 but not in Firefox v9.0 on Windows 10 Pro.

avatar brianteeman
brianteeman - comment - 19 Jun 2021

@Quy can you please confirm the version of Firefox you are using?

avatar Quy
Quy - comment - 19 Jun 2021

Firefox 89.0.1

avatar brianteeman
brianteeman - comment - 19 Jun 2021

Still cannot replicate your problem

image

avatar Quy
Quy - comment - 19 Jun 2021

So you can crop/resize/rotate and save & close/open the image again? I will test again shortly and let you know.

avatar brianteeman
brianteeman - comment - 19 Jun 2021

ah I see - its failing at the save part

avatar brianteeman
brianteeman - comment - 19 Jun 2021

Wondering if the save in the crop/resize plugin is actually saving it as a jpg but keeping the extension as webp which chrome has no problem with but firefox does??

avatar Quy
Quy - comment - 19 Jun 2021
avatar brianteeman
brianteeman - comment - 19 Jun 2021

Its an upstream problem with the cropper.js library

fengyuanchen/cropperjs#800 (comment)

avatar joomla-cms-bot joomla-cms-bot - change - 19 Jun 2021
Category Administration com_media NPM Change Repository SQL Installation Postgresql Libraries Administration com_media NPM Change Repository JavaScript SQL Installation Postgresql Libraries
avatar brianteeman
brianteeman - comment - 19 Jun 2021

Could you please retest. I found and fixed an error in the js which I have now fixed and it would appear to resolve the issue.

Note that if it doesnt then this js correction is still needed

avatar Quy
Quy - comment - 19 Jun 2021

It is still an issue with crop.

Edit an image.
Crop the image.
Click Save & Close button.
See browser's console.

avatar brianteeman
brianteeman - comment - 19 Jun 2021

are rotate and resize fixed?

avatar Quy
Quy - comment - 19 Jun 2021

Same error for all 3 actions.

avatar brianteeman
brianteeman - comment - 20 Jun 2021

Ok so the conclusion is that it is not a bug in the js here or the cropper library. Firefox does not identify webp images when used with the HTMLCanvasElement.toDataURL() method and it just falls back to png

Reference MDN
Tests Tests

image

image

avatar richard67
richard67 - comment - 20 Jun 2021

Reference MDN says:

If the requested type is not image/png, but the returned value starts with data:image/png, then the requested type is not supported.

I have no words. That seems to me like if my function returns a "Successfully completed the xyz task." message for the "abc" task, the task has failed.

avatar brianteeman
brianteeman - comment - 2 Jul 2021

Closed as image editing for webp doesnt work with cropperjs and firefox windows

avatar brianteeman brianteeman - change - 2 Jul 2021
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2021-07-02 21:08:02
Closed_By brianteeman
Labels Added: Conflicting Files
avatar brianteeman brianteeman - close - 2 Jul 2021

Add a Comment

Login with GitHub to post a comment