dokuwiki icon indicating copy to clipboard operation
dokuwiki copied to clipboard

extend check for image types with svg and webp

Open Klap-in opened this issue 2 years ago • 5 comments

More like https://github.com/dokuwiki/dokuwiki/commit/29d63aa571c7ffaccb323c0bb2a6a230f95c0d5d

e.g. https://codesearch.dokuwiki.org/xref/dokuwiki/lib/scripts/media.js#716 https://codesearch.dokuwiki.org/xref/dokuwiki/inc/search.php#221 https://codesearch.dokuwiki.org/xref/dokuwiki/inc/media.php#1129 and other https://codesearch.dokuwiki.org/xref/dokuwiki/inc/Ui/MediaDiff.php#90 https://codesearch.dokuwiki.org/xref/dokuwiki/inc/parser/xhtml.php#1814 Probably more…

Does JpegMeta has limited support for file types? I guess so, see for replacement suggestions in #1970

Klap-in avatar Jul 17 '23 21:07 Klap-in

Could it be an option to e.g. write a function in common.php that checks file extensions and returns a requested value? Maybe it would then also make sense to get the allowed file extensions from mime.conf (default) or include them as an option (array or string).

If the direction would be okay like that, then I would try my hand at it.

saggi-dw avatar Jul 27 '23 14:07 saggi-dw

It is more then just checking extension probably. My impression is that these checks here are for switching between handling as image or as non-image. For that check indeed a function might be helpful as well. So far I remember it right now, checking if a file or image is allowed, or should be only downloadable, is already happening at another place, and is indeed based at the mime config.

If generalizing the check for if file should be treated as image, then all the occurrences should support all these files. I guess at most places this is the case, but maybe e.g. jpegmeta could be a limitation. So this update needs a bit of testing.

Klap-in avatar Jul 27 '23 16:07 Klap-in

If simple check, without involving mime config, is working, I propose not to add it. Only add it if really needed, please keep things simple as possible.

Klap-in avatar Jul 27 '23 16:07 Klap-in

If simple check, without involving mime config, is working, I propose not to add it. Only add it if really needed, please keep things simple as possible.

Yes, as simple as possible. I was thinking more of a central place for allowed formats. That new formats would not have to be specified extra. There are many preg_match with allowed extensions. After the idea e.g.: is_valid_pictureext (returns true/false) that the function gets the data from the mime.conf was only an idea, since there the supported formats are already listed.

I was thinking that in the future you would then only have to change the supported formats in one place.

Optionally, you could also build or use tests that check images for consistency (like media_contentcheck in media.php). But that would no longer be as simple as possible.

saggi-dw avatar Jul 28 '23 09:07 saggi-dw

My understanding is that the mime config let the wiki admin decide which files are allowed to upload (so far I see now checked when trying to upload), and which from these files are allowed to show/play by the browser (i.e. pictures/movies/audio/etc) vs which are only allowed to be downloaded (only checked when an image url is called directly, not e.g. if an images is embedded).

The check here is additional to the mime type handling: if the files are handled by the wiki (and thus pass the mime filter already), then we have a special treatment for some images. The check here is in my understanding about this special treatment.

I saw now there is also a media_supportedav() for video formats supported on some places. Probably something similar such as media_supported_images() sounds logic.

(In the image handling there is still quite some legacy code grown in time. A lot can be improved, but let’s make small steps)

Klap-in avatar Jul 28 '23 13:07 Klap-in