griffer / moodle-repository_resourcespace

ResourceSpace Moodle filepicker integration
2 stars 3 forks source link

Image File Types #3

Open mrvinceo opened 3 years ago

mrvinceo commented 3 years ago

Thanks for the work on this plugin - we're hoping it could help us adopt Resource Space!

We're able to successfully select files from RS using the File resource, but attempting to bring in images through the editor using the RS Repository throws an invalidfiletype error (* line 146 of /repository/repository_ajax.php: moodle_exception thrown); is this not part of the typical usecase of the plugin, or is it perhaps a version compatibilty issue with my installation of Moodle (3.9)?

griffer commented 3 years ago

Are you able to upload local images from your computer to the editor in moodle?

I no longer work at the school I wrote this plugin at/for, so i don't have easy access to a test setup of moodle and resourcespace, to check for any incompatibility with moodle 3.9.

I will see if i can dig up my old scripts and notes, and spin up a test.

mrvinceo commented 3 years ago

Thanks for the quick reply! Yes, I'm able to upload images and other repos work ok for images via the editor. I could be wrong, but it looks to be the source attribute, which is still referencing the resource ref rather than the url, like other repos like Wikimedia.

E.g., it's displaying 'source: 2,jpg' in the console rather than 'source: https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Bus_1510.jpg/1024px-Bus_1510.jpg'. Looks to be set with this line: 'source' => sprintf('%s,%s', $resource->ref, $resource->file_extension), which your comments acknowledge brings in the ref as the source can't be brought in at that point, although the File resource does work, so the url is fetched at some point.

griffer commented 3 years ago

Okay i got a small test setup up and running.

For some reason the mimetypes of the file is not reported correctly to moodle. If i remove the check from moodles sourcecode, the plugin still functions. The files are however transferred without their file extensions.

Im not quite sure what might be causing it, perhaps moodle changed something in their plugin api, or it could be resourcespace who changed things around...

I hope i have some time to look into it a bit later

mrvinceo commented 3 years ago

Many thanks for the update! Out of interest, where is the mimetype checked in Moodle core; is it just the 'mimetypes' => $accepted_types line in filepicker.php?

Thanks again for taking a look

griffer commented 3 years ago

I can't remember what the specific file is called off the top of my head. But when enabling debugging mode it will list the specific file where the supported filetype check takes place.

The selected file gets uploaded to a tmp folder in moodledata correctly, so the problem seems to be Moodle related and not in Resourcespace. I skimmed over Moodles filepicker api documentation, looking for anything that has been changed, but i couldn't see anything different. So it will require some more digging.

nadavkav commented 2 years ago

Thank you very much for this plugin!

We are also experiencing similar issue, using Moodle 3.9 (latest stable minor) with repository_resourcespac version 2017030401