cancel
Showing results for 
Search instead for 
Did you mean: 

WYSIWYG media library sort order

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

WYSIWYG media library sort order

I'm migrating a client from Magento 1 to 2 and I've uploaded all of their images and photos to /pub/media in two separate folders.

I can see these folders when using the wysiwyg editor and select an image, but the images appear in a random sequence rather than alphabetically. Is there a way of chnaging the sort order of the media library elements? 

2 REPLIES 2

Re: WYSIWYG media library sort order

Hello @jgd1955 

 

Please follow the below steps:

  1. Navigate to vendor\magento\module-cms\Model\Wysiwyg\Images\Storage.php
  2. Go to public function getFilesCollection 
  3. Make changes in the below code as per your requirements:
    setOrder(
                'mtime',
                \Magento\Framework\Data\Collection::SORT_ORDER_ASC
            )

I hope it helps.

---
If you've found my answer useful, please give"Kudos" and "Accept as Solution"

Re: WYSIWYG media library sort order

Thanks

I checked the file and can see the string )->setOrder('mtime',\Magento\Framework\Data\Collection:Smiley FrustratedORT_ORDER_ASC);
within the following section at line 317 

/**
* Return files
*
* @param string $path Parent directory path
* @param string $type Type of storage, e.g. image, media etc.
* @return \Magento\Framework\Data\Collection\Filesystem
*/

I guess I've got to add that string in another section?