Is there a way to allow .jpeg as well as .jpg?
Ultimately I think we should be able to specify any extension like you can in Processwire:
Is there a way to allow .jpeg as well as .jpg?
Ultimately I think we should be able to specify any extension like you can in Processwire:
why? its the same anyway.
Correct.
Itâs just my content comes from another program that for some reason outputs both so some image links are broken. I will look into why it is doing that.
I would like to see the ability to specify allowed extensions however.
You can use panel.file.upload permission to check for file extensions on upload. Have a look at the section âAllow uploads based on the type of fileâ.
The string replacement (jpeg
=> jpg
) is hardcoded in the Upload class (toolkit/lib/upload.php):
$safeExtension = str_replace('jpeg', 'jpg', str::lower($extension));
so unless you prevent sanitization of the filename via blueprint or modify the source code, I donât think you can do anything to prevent sanitization of the extension.
could a hook be used to rename the file back to jpeg after uploading, or does this trigger sanitation?
inside hook using toolkits f class in file and meta file?
I donât think so, because the file upload hook does not have an old file object. Therefore, you wouldnât know the original file extension, if both .jpeg and .jpg are used.
@macgyver This is not a matter of allowed file extensions, because files with the extension .jpeg are valid uploadable files. The thing that happens is that they are renamed with that piece of code I quoted in my last post.
Where can I specify additional valid uploadable files?
You could use permissions to prevent upload of certain files, but this will not really help you with the extension problem. As I said, the problem is not that your .jpeg files cannot be uploaded, but that their extension is changed.
There is no config setting comparable to the Processwire setting you mentioned above.
codeline is here.
@macgyver
you could replace this line in your kirby toolkit installation.
// $safeExtension = str_replace('jpeg', 'jpg', str::lower($extension));
$safeExtension = str::lower($extension);
that âfix/hackâ will be gone when updating of course. not really a good solution but should work.
filetypes are here
I agree, not ideal, but as long as you keep track of such changes in a todo list for updates, it should not be a problem.
@bnomei Thanks! I was looking for that