Problem/Motivation
The file extensions to be used to retrieve the list of files in the dropdown image selector is hardcoded.
protected function getList() {
$filelist = array();
if (is_dir($this->configuration['path']) && $handle = opendir($this->configuration['path'])) {
while ($file = readdir($handle)) {
if (preg_match("/\.gif|\.png|\.jpg|\.jpeg$/i", $file) == 1) { // @todo make this list dependent on toolkit capabilities
$filelist[] = $file;
}
}
closedir($handle);
}
return $filelist;
}
Proposed resolution
Test files' extension against ImageFactory::getSupportedExtensions.
Remaining tasks
Write patch
User interface changes
List of image files will include any image supported by the default toolkit.
API changes
None
Data model changes
None
Comments
Comment #2
slashrsm commentedComment #3
joshi.rohit100Comment #4
mondrakeGiven current status of D8 HEAD, if we do this now we will miss .jpg and .jpe files when GD toolkit is in use. I suggest to postpone till when #1014816: Allow image fields to use any extensions the current image toolkit supports (instead of hard-coding jpg, png and gif only) lands.
Comment #5
mondrakeComment #6
mondrake#2477381: GDToolkit::getSupportedExtensions returns incomplete list has been committed to 8.2.x. We need to wait for the commit to 8.1.x and set the required Drupal core version to the first patch one.
Also, needs tests.
Comment #7
gábor hojtsyComment #8
mondrakeChanged test to ensure a .jpe image is listed; added an test .jpe image file
Comment #10
mondrake#8 is green.
Comment #11
mondrake#6: created #2787973: Require Drupal 8.2.0.
Comment #13
mondrake