diff --git a/typo3/sysext/core/Classes/Resource/Service/MagicImageService.php b/typo3/sysext/core/Classes/Resource/Service/MagicImageService.php
index 0748f19a7ef04f392e45589e575ba4fcf784b607..325eddfcd59062bdd1093f4554189419680054de 100644
--- a/typo3/sysext/core/Classes/Resource/Service/MagicImageService.php
+++ b/typo3/sysext/core/Classes/Resource/Service/MagicImageService.php
@@ -41,7 +41,7 @@ class MagicImageService {
 	 *
 	 * @param Resource\File $imageFileObject: the original image file
 	 * @param array $fileConfiguration (width, height, maxW, maxH)
-	 * @return ProcessedFile
+	 * @return Resource\ProcessedFile
 	 */
 	public function createMagicImage(Resource\File $imageFileObject, array $fileConfiguration) {
 		// Process dimensions
diff --git a/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php b/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
index 547a61dc4c18bbe25810644c2fc6a9b9d6edec0b..1beba913e68631ff986aef08e0b3000da2ca938c 100644
--- a/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
+++ b/typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
@@ -1801,6 +1801,7 @@ class ElementBrowser {
 		foreach ($files as $fileObject) {
 			$fileExtension = $fileObject->getExtension();
 			// Thumbnail/size generation:
+			$imgInfo = array();
 			if (GeneralUtility::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), strtolower($fileExtension)) && !$noThumbs) {
 				$imageUrl = $fileObject->process(
 					\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW,
@@ -1827,16 +1828,16 @@ class ElementBrowser {
 				'fileExt' => $fileExtension,
 				'fileIcon' => $icon
 			);
-			if ($this->act === 'plain' && ($imgInfo[0] > $this->plainMaxWidth || $imgInfo[1] > $this->plainMaxHeight) || !GeneralUtility::inList('jpg,jpeg,gif,png', $fileExtension)) {
-				$ATag = '';
-				$ATag_alt = '';
-				$ATag_e = '';
-				$bulkCheckBox = '';
-			} else {
+			if ($this->fileIsSelectableInFileList($fileObject, $imgInfo)) {
 				$ATag = '<a href="#" onclick="return BrowseLinks.File.insertElement(\'file_' . $filesIndex . '\');">';
 				$ATag_alt = substr($ATag, 0, -4) . ',1);">';
 				$bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_' . $filesIndex . '" value="0" /> ';
 				$ATag_e = '</a>';
+			} else {
+				$ATag = '';
+				$ATag_alt = '';
+				$ATag_e = '';
+				$bulkCheckBox = '';
 			}
 			// Create link to showing details about the file in a window:
 			$Ahref = $GLOBALS['BACK_PATH'] . 'show_item.php?type=file&table=_FILE&uid='
@@ -1895,6 +1896,19 @@ class ElementBrowser {
 		return $out;
 	}
 
+	/**
+	 * Checks if the given file is selectable in the file list.
+	 *
+	 * By default all files are selectable. This method may be overwritten in child classes.
+	 *
+	 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
+	 * @param array $imgInfo Image dimensions from \TYPO3\CMS\Core\Imaging\GraphicalFunctions::getImageDimensions()
+	 * @return bool TRUE if file is selectable.
+	 */
+	protected function fileIsSelectableInFileList(\TYPO3\CMS\Core\Resource\FileInterface $file, array $imgInfo) {
+		return TRUE;
+	}
+
 	/**
 	 * Render list of folders.
 	 *
diff --git a/typo3/sysext/rtehtmlarea/Classes/SelectImage.php b/typo3/sysext/rtehtmlarea/Classes/SelectImage.php
index c9333b50feab7231cafb15fbd9465f6489afbf54..edd50b0cd439886476cc639062f1fd3cf3b9899c 100644
--- a/typo3/sysext/rtehtmlarea/Classes/SelectImage.php
+++ b/typo3/sysext/rtehtmlarea/Classes/SelectImage.php
@@ -38,6 +38,13 @@ use TYPO3\CMS\Core\Resource;
  */
 class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 
+	/**
+	 * These file extensions are allowed in the "plain" image selection mode.
+	 *
+	 * @const
+	 */
+	const PLAIN_MODE_IMAGE_FILE_EXTENSIONS = 'jpg,jpeg,gif,png';
+
 	/**
 	 * @todo Define visibility
 	 */
@@ -54,8 +61,18 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 
 	protected $defaultClass;
 
+	/**
+	 * Relevant for RTE mode "plain": the maximum width an image must have to be selectable.
+	 *
+	 * @var int
+	 */
 	protected $plainMaxWidth;
 
+	/**
+	 * Relevant for RTE mode "plain": the maximum height an image must have to be selectable.
+	 *
+	 * @var int
+	 */
 	protected $plainMaxHeight;
 
 	protected $magicMaxWidth;
@@ -133,7 +150,7 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 		$pArr[1] = implode(':', array($this->editorNo, $this->sys_language_content));
 		$pArr[2] = $this->RTEtsConfigParams;
 		if ($this->act == 'dragdrop' || $this->act == 'plain') {
-			$this->allowedFileTypes = explode(',', 'jpg,jpeg,gif,png');
+			$this->allowedFileTypes = explode(',', self::PLAIN_MODE_IMAGE_FILE_EXTENSIONS);
 		}
 		$pArr[3] = implode(',', $this->allowedFileTypes);
 		$this->bparams = implode('|', $pArr);
@@ -153,6 +170,7 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 	 * Initialize hook objects implementing the hook interface
 	 *
 	 * @return 	void
+	 * @throws \UnexpectedValueException
 	 */
 	protected function initHookObjects() {
 		if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']['browseLinksHook'])) {
@@ -637,8 +655,8 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 	 * Session data for this class can be set from outside with this method.
 	 * Call after init()
 	 *
-	 * @param 	array		Session data array
-	 * @return 	array		Session data and boolean which indicates that data needs to be stored in session because it's changed
+	 * @param array $data Session data array
+	 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
 	 * @todo Define visibility
 	 */
 	public function processSessionData($data) {
@@ -661,9 +679,7 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 	}
 
 	/**
-	 * [Describe function...]
-	 *
-	 * @return 	[type]		...
+	 * @return string
 	 * @todo Define visibility
 	 */
 	public function main_rte() {
@@ -732,8 +748,8 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 					}
 				}
 				// Get the selected folder
+				$selectedFolder = FALSE;
 				if ($this->expandFolder) {
-					$selectedFolder = FALSE;
 					$fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
 					if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
 						// it's a folder
@@ -762,8 +778,9 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 					$this->content .= $uploadForm;
 				}
 				// Render the filelist if there is a folder selected
+				$files = '';
 				if ($selectedFolder) {
-					$files = $this->TBE_expandFolder($selectedFolder, $this->act === 'plain' ? 'jpg,jpeg,gif,png' : $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInRTEimageSelect'));
+					$files = $this->TBE_expandFolder($selectedFolder, $this->act === 'plain' ? self::PLAIN_MODE_IMAGE_FILE_EXTENSIONS : $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInRTEimageSelect'));
 				}
 				// Setup filelist indexed elements:
 				$this->doc->JScode .= $this->doc->wrapScriptTags('BrowseLinks.addElements(' . json_encode($this->elements) . ');');
@@ -806,14 +823,15 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 						$this->expandFolder = $cmpPath;
 					}
 				}
+				$selectedFolder = FALSE;
 				if ($this->expandFolder) {
 					try {
 						$selectedFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
-					} catch (Exception $e) {
-						$selectedFolder = FALSE;
+					} catch (\Exception $e) {
 					}
 				}
 				// Render the filelist if there is a folder selected
+				$files = '';
 				if ($selectedFolder) {
 					$files = $this->TBE_dragNDrop($selectedFolder, implode(',', $this->allowedFileTypes));
 				}
@@ -999,4 +1017,23 @@ class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 		}
 	}
 
+	/**
+	 * Checks if the given file is selectable in the file list.
+	 *
+	 * In "plain" RTE mode only image files with a maximum width and height are selectable.
+	 *
+	 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
+	 * @param array $imgInfo Image dimensions from \TYPO3\CMS\Core\Imaging\GraphicalFunctions::getImageDimensions()
+	 * @return bool TRUE if file is selectable.
+	 */
+	protected function fileIsSelectableInFileList(\TYPO3\CMS\Core\Resource\FileInterface $file, array $imgInfo) {
+		return (
+			$this->act !== 'plain'
+			|| (
+				GeneralUtility::inList(self::PLAIN_MODE_IMAGE_FILE_EXTENSIONS, strtolower($file->getExtension()))
+				&& $imgInfo[0] <= $this->plainMaxWidth
+				&& $imgInfo[1] <= $this->plainMaxHeight
+			)
+		);
+	}
 }