U4-9293 - Search the entire media section in Media Picker when inserting an image into content

Created by Emil Rasmussen 16 Dec 2016, 12:04:13 Updated by Sebastiaan Janssen 02 Nov 2017, 09:41:03

Relates to: U4-10612

Subtask of: U4-9272

Currently the media picker only filters the current folder of the media section tree. When dealing with large media libraries it would be advantageous to be able to search the entire depth of the media tree.

1 Attachments

Comments

Lee Cook 29 Jan 2017, 19:25:05

Our editors regularly moan about this as well. Would be a nice UX fix.


Asbjørn Riis-Knudsen 30 Jan 2017, 08:01:32

Yes. It is very unintuitive that the Content Picker has a search field, but the Media Picker has a filter field. I know there's a difference, but for most people search or filter is pretty much the same thing...


Matthew 07 Feb 2017, 20:22:06

This has been a gripe of mine since I've started using Umbraco


Mads Rasmussen 13 Feb 2017, 13:44:42

PR: https://github.com/umbraco/Umbraco-CMS/pull/1753

What to test:

  • search the media library including media from sub folders
  • pagination on search works
  • search respects start node


Shannon Deminick 13 Feb 2017, 23:16:31

@madsrasmussen I've added comments to this PR I have concerns over this c# code due to both security and code duplication, it seems to me that it would be better suited to use the EntityController directly ? Let me know why we cannot do this, is it because the entity models don't contain all required data? If so we should see what we can do since the EntityBasic can contain an additionaldata collection to fill with data that may be required. We should also not have all of this code duplication.


Mads Rasmussen 15 Feb 2017, 10:33:12

@Shandem I'm a little confused on this one :D Anything we need to do to get this rolling? I have added an issue for the users, with no access to media, being logged out: http://issues.umbraco.org/issue/U4-9533


Shannon Deminick 16 Feb 2017, 07:15:49

Adding notes from PR:

n the meantime, I'm leaving this in review, I'll remove all of the new code duplication that exists in the MediaController (ExamineSearch) (this is 100% unnecessary). We can keep MediaController.Search if we want, in which case we can add that to ContentController too. I'll also add EntityController.GetDescendants and EntityController.GetChildren since we need that for http://issues.umbraco.org/issue/U4-9470

So another thing to know about EntityController vs Media/Content Controller - The EntityController returns generic entities for all types, generally without any of it's properties. Media is slightly different because it's properties are put into the AdditionalData/metaData properties because for the most part all media user properties need to be known since that is where the media info is actually stored. The Entity returned from EntityController also tells you if the item HasChildren, the Content/Media Controllers do not. This is because the Content and Media objects returned from those controllers are complex models including all properties, content type, property type, etc... information. It is far to inefficient to make these models more complicated by also including if they have children.


Emil Wangaa 16 Feb 2017, 14:08:12

@Shandem I've removed the duplicate code ExamineSearch and search endpoint from the MediaController. I've merged in the code from http://issues.umbraco.org/issue/U4-9470 to get the EntityService.GetPagedDescendants functionality and added the missing EntityController.GetPagedDescendants so we can use this one for the searching the media section from the media picker. So http://issues.umbraco.org/issue/U4-9470 should be merged in before this task. @madsrasmussen is working on updating the mediapicker to use the EntityController.GetPagedDescendants endpoint right now.


Mads Rasmussen 16 Feb 2017, 19:01:46

@Shandem and @emil:

I have updated the UI to use getPagedDescendants now.

I have found two issues:

  • It looks like images are returned twice in the result
  • I get a 404 if I have spaces in my filter query


Emil Wangaa 17 Feb 2017, 09:03:15

@madsrasmussen I think I've fixed the 404. It happened for me when the endpoint didn't find anything then it was returning pagesize and pagenumber = 0 and then we were setting those value for the picker, so at next request it would send 0 for pagesize and pagenumber and the endpoint doesn't like that. I also fixed a bug where the mediagrid would fail loading when a folder was part of the search result. It's all in this commit: https://github.com/umbraco/Umbraco-CMS/pull/1753/commits/4dabb606e7e0daf7adb9c71c273dd62b7018b8e5

I haven't been able to reproduce the duplicate images in the result. Could you see if it's actually the same images that are returned?


Mads Rasmussen 20 Feb 2017, 12:30:10

@emil and @Shandem : I did some more testing on the duplicate images issue and the issue is it also searches the recycle bin. So I had two of every image but one of the sets were placed in the recycle bin.

The issue might be related to these: http://issues.umbraco.org/issue/U4-9521 and http://issues.umbraco.org/issue/U4-9522


Shannon Deminick 21 Feb 2017, 04:45:25

I've pushed a fix for the searching in the recycle bin here: febeb82d10607dae81042983c29ff39f28952319 , I've left a comment on each of those other issues

@emil I've assigned back to you for review


Emil Wangaa 21 Feb 2017, 10:58:26

Tested and verified that it doesn't find anything that is trashed now and I haven't been able to reproduce the duplicate images. The added code looks good and the search works great now.


Florin Lazau 05 May 2017, 13:46:52

This is awesome. Is it possible to have this functionality on lists? I have enabled list view on and in that list I documents (direct in list) but also I have documents grouped in folders. When I search I would like to get the result from all subfolders.

Many thanks, Florin


Priority: Normal

Type: Feature (request)

State: Fixed

Assignee:

Difficulty: Easy

Category: UI

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.6.0

Sprint: Sprint 53

Story Points: 1.5

Cycle: