diff --git a/badges/classes/form/badge.php b/badges/classes/form/badge.php index faa64a651e9..f5bc8f4bb8a 100644 --- a/badges/classes/form/badge.php +++ b/badges/classes/form/badge.php @@ -70,7 +70,7 @@ class badge extends moodleform { $mform->addRule('description', null, 'required'); $str = $action == 'new' ? get_string('badgeimage', 'badges') : get_string('newimage', 'badges'); - $imageoptions = array('maxbytes' => 262144, 'accepted_types' => array('web_image')); + $imageoptions = array('maxbytes' => 262144, 'accepted_types' => array('optimised_image')); $mform->addElement('filepicker', 'image', $str, null, $imageoptions); if ($action == 'new') { diff --git a/lang/en/mimetypes.php b/lang/en/mimetypes.php index cbcd32914fc..83f4257b334 100644 --- a/lang/en/mimetypes.php +++ b/lang/en/mimetypes.php @@ -74,6 +74,7 @@ $string['group:html_track'] = 'HTML track files'; $string['group:html_video'] = 'Video files natively supported by browsers'; $string['group:image'] = 'Image files'; $string['group:media_source'] = 'Streaming media'; +$string['group:optimised_image'] = 'Image files to be optimised, such as badges'; $string['group:presentation'] = 'Presentation files'; $string['group:sourcecode'] = 'Source code'; $string['group:spreadsheet'] = 'Spreadsheet files'; diff --git a/lib/classes/filetypes.php b/lib/classes/filetypes.php index 99f813fa692..aec115b3aed 100644 --- a/lib/classes/filetypes.php +++ b/lib/classes/filetypes.php @@ -106,7 +106,8 @@ abstract class core_filetypes { 'groups' => array('spreadsheet')), 'gslides' => array('type' => 'application/vnd.google-apps.presentation', 'icon' => 'powerpoint', 'groups' => array('presentation')), - 'gif' => array('type' => 'image/gif', 'icon' => 'gif', 'groups' => array('image', 'web_image'), 'string' => 'image'), + 'gif' => array('type' => 'image/gif', 'icon' => 'gif', 'groups' => array('image', 'web_image', 'optimised_image'), + 'string' => 'image'), 'gtar' => array('type' => 'application/x-gtar', 'icon' => 'archive', 'groups' => array('archive'), 'string' => 'archive'), 'tgz' => array('type' => 'application/g-zip', 'icon' => 'archive', 'groups' => array('archive'), 'string' => 'archive'), @@ -135,9 +136,12 @@ abstract class core_filetypes { 'jmt' => array('type' => 'text/xml', 'icon' => 'markup'), 'jmx' => array('type' => 'text/xml', 'icon' => 'markup'), 'jnlp' => array('type' => 'application/x-java-jnlp-file', 'icon' => 'markup'), - 'jpe' => array('type' => 'image/jpeg', 'icon' => 'jpeg', 'groups' => array('image', 'web_image'), 'string' => 'image'), - 'jpeg' => array('type' => 'image/jpeg', 'icon' => 'jpeg', 'groups' => array('image', 'web_image'), 'string' => 'image'), - 'jpg' => array('type' => 'image/jpeg', 'icon' => 'jpeg', 'groups' => array('image', 'web_image'), 'string' => 'image'), + 'jpe' => array('type' => 'image/jpeg', 'icon' => 'jpeg', 'groups' => array('image', 'web_image', 'optimised_image'), + 'string' => 'image'), + 'jpeg' => array('type' => 'image/jpeg', 'icon' => 'jpeg', 'groups' => array('image', 'web_image', 'optimised_image'), + 'string' => 'image'), + 'jpg' => array('type' => 'image/jpeg', 'icon' => 'jpeg', 'groups' => array('image', 'web_image', 'optimised_image'), + 'string' => 'image'), 'jqz' => array('type' => 'text/xml', 'icon' => 'markup'), 'js' => array('type' => 'application/x-javascript', 'icon' => 'text', 'groups' => array('web_file')), 'json' => array('type' => 'application/json', 'icon' => 'text'), @@ -205,7 +209,8 @@ abstract class core_filetypes { 'php' => array('type' => 'text/plain', 'icon' => 'sourcecode'), 'pic' => array('type' => 'image/pict', 'icon' => 'image', 'groups' => array('image'), 'string' => 'image'), 'pict' => array('type' => 'image/pict', 'icon' => 'image', 'groups' => array('image'), 'string' => 'image'), - 'png' => array('type' => 'image/png', 'icon' => 'png', 'groups' => array('image', 'web_image'), 'string' => 'image'), + 'png' => array('type' => 'image/png', 'icon' => 'png', 'groups' => array('image', 'web_image', 'optimised_image'), + 'string' => 'image'), 'pps' => array('type' => 'application/vnd.ms-powerpoint', 'icon' => 'powerpoint', 'groups' => array('presentation')), 'ppt' => array('type' => 'application/vnd.ms-powerpoint', 'icon' => 'powerpoint', 'groups' => array('presentation')), 'pptx' => array('type' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', diff --git a/lib/filelib.php b/lib/filelib.php index 36a85d87561..b2b13988647 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -1639,6 +1639,7 @@ function download_file_content($url, $headers=null, $postdata=null, $fullrespons * commonly used in moodle the following groups: * - web_image - image that can be included as in HTML * - image - image that we can parse using GD to find it's dimensions, also used for portfolio format + * - optimised_image - image that will be processed and optimised * - video - file that can be imported as video in text editor * - audio - file that can be imported as audio in text editor * - archive - we can extract files from this archive diff --git a/lib/form/tests/filetypes_util_test.php b/lib/form/tests/filetypes_util_test.php index 7fb1b5f95b0..355fefe4e7b 100644 --- a/lib/form/tests/filetypes_util_test.php +++ b/lib/form/tests/filetypes_util_test.php @@ -302,10 +302,10 @@ class filetypes_util_testcase extends advanced_testcase { // All these three files are in both "image" and also "web_image" // groups. We display both groups. $data = $util->data_for_browser('jpg png gif', true, '.gif'); - $this->assertEquals(2, count($data)); + $this->assertEquals(3, count($data)); $this->assertTrue($data[0]->key !== $data[1]->key); foreach ($data as $group) { - $this->assertTrue(($group->key === 'image' || $group->key === 'web_image')); + $this->assertTrue(($group->key === 'image' || $group->key === 'web_image' || $group->key === 'optimised_image')); $this->assertEquals(3, count($group->types)); $this->assertFalse($group->selectable); foreach ($group->types as $ext) { @@ -317,11 +317,11 @@ class filetypes_util_testcase extends advanced_testcase { } } - // There is a group web_image which is a subset of the group image. The - // file extensions that fall into both groups will be displayed twice. + // The groups web_image and optimised_image are a subset of the group image. The + // file extensions that fall into these groups will be displayed thrice. $data = $util->data_for_browser('web_image'); foreach ($data as $group) { - $this->assertTrue(($group->key === 'image' || $group->key === 'web_image')); + $this->assertTrue(($group->key === 'image' || $group->key === 'web_image' || $group->key === 'optimised_image')); } // Check that "All file types" are displayed first. diff --git a/user/edit.php b/user/edit.php index 7fc19ffb94e..ec1a81fba18 100644 --- a/user/edit.php +++ b/user/edit.php @@ -165,7 +165,7 @@ $filemanagercontext = $editoroptions['context']; $filemanageroptions = array('maxbytes' => $CFG->maxbytes, 'subdirs' => 0, 'maxfiles' => 1, - 'accepted_types' => 'web_image'); + 'accepted_types' => 'optimised_image'); file_prepare_draft_area($draftitemid, $filemanagercontext->id, 'user', 'newicon', 0, $filemanageroptions); $user->imagefile = $draftitemid; // Create form. diff --git a/user/editadvanced.php b/user/editadvanced.php index 07fc5e06315..fea54a6bf08 100644 --- a/user/editadvanced.php +++ b/user/editadvanced.php @@ -145,7 +145,7 @@ $filemanagercontext = $editoroptions['context']; $filemanageroptions = array('maxbytes' => $CFG->maxbytes, 'subdirs' => 0, 'maxfiles' => 1, - 'accepted_types' => 'web_image'); + 'accepted_types' => 'optimised_image'); file_prepare_draft_area($draftitemid, $filemanagercontext->id, 'user', 'newicon', 0, $filemanageroptions); $user->imagefile = $draftitemid; // Create form. diff --git a/user/externallib.php b/user/externallib.php index 0d7daad5fa5..90c9bd423db 100644 --- a/user/externallib.php +++ b/user/externallib.php @@ -574,7 +574,7 @@ class core_user_external extends external_api { $filemanageroptions = array('maxbytes' => $CFG->maxbytes, 'subdirs' => 0, 'maxfiles' => 1, - 'accepted_types' => 'web_image'); + 'accepted_types' => 'optimised_image'); $transaction = $DB->start_delegated_transaction(); @@ -1707,7 +1707,12 @@ class core_user_external extends external_api { throw new moodle_exception('noprofileedit', 'auth'); } - $filemanageroptions = array('maxbytes' => $CFG->maxbytes, 'subdirs' => 0, 'maxfiles' => 1, 'accepted_types' => 'web_image'); + $filemanageroptions = array( + 'maxbytes' => $CFG->maxbytes, + 'subdirs' => 0, + 'maxfiles' => 1, + 'accepted_types' => 'optimised_image' + ); $user->deletepicture = $params['delete']; $user->imagefile = $params['draftitemid']; $success = core_user::update_picture($user, $filemanageroptions);