Revamping the media section

Making the dream a reality

In CodeGarden 2019 Jeffrey Shoemaker did a talk about his dreams for Umbraco

He talked about his dream of a better media section 

A lot of what he said aligned with thoughts I'd be having with media

Would it now be possible to make these dreams come true

What's wrong with the media section?

Let's take a look...

The media tree

Makes sense for content, but for media it requires a level of organisation which isn't intuitive
 

Every site I've used has ended up with hundreds of images in the root
 

No drag and drop

The media tree

Is this the optimum way to find the media you are after?

Search

Searches just images in the current folder, even when in root

Would be nice to have an option to search all media, or all child folders

Very limited data we can search on, just the name

Sorting

Doesn't look too intimidating when you have 3 items, but when you have 300 it's not really usable

Doesn't show thumbnails for images

 

Is this the most friendly way to sort items?

What about the media picker?

Let's take a look...

Upload

Most editors will click the upload and upload their media

This uploads their media into the root of the media section


Does every image even need to be in the media library?

Subfolders

No visual clues about their content

 

Look a bit weird with just the icon

I rate it 3.6

Not great

Not terrible

The fundamental issue:

Content exists in the structure of the site

Content has a lot of textual and meta information

Media is attached to an image, file, or other external source

Media has very little content, or meta information

Media != Content

What would the dream media section and picker look like?

Why is the UI almost identical?

Media Picker

What are editors trying to do when using a media picker?

  • Upload new media
  • Select existing media (or crops) from the media library

Uploading a new media item...

Some images we'll want to reuse, but often this image is something we'll just want for this single piece of content and that is it.
 

In that case does it need to live in the media library?

Media tree shows when you check to save media to media library

Select whether you are uploading or using an existing item

Select an existing item

This is very much based on the current UI.

But let's make it a bit more information rich

Media Picker 2.0

Selecting an existing item from the media library...

 

This is pretty much the current UI however could we make that media easier to find

Add meta data

Give some extra insight into the contents of folders

Media Section

What are editors trying to do when using the media section?

  • Find an existing media item
  • Upload some media for general use
  • Reorganise media

Media Section v2.0

Give some extra insight into the contents of folders

Filtering and faceting

Add a way of finding media by where it's used

Is it possible to do this?

When I talked about this in 2019 it wasn't really possible to do this. In my talk about media AI, I ended up hiding the existing media section and making my own. I created a new data type with it's own picker to replace the standard media picker.

Now Umbraco since v14 has extensions points that will let your replace core sections of the Backoffice UI

Some caveats

I'm new to v14+, Typescript, Lit etc.

I'm going to try and show you how I went about figuring how to do this, what worked, which resources are useful and where the problems lie.

I wanted this to be a demonstration of learning how to do this, hopefully this will smooth the learning curve for others

The approach

I had planned to spend 5 full days to learn what I needed to do and get as far along as I could.

Whatever I managed to build at the end of those days is what I'm going to show today.

Step 1 - Setup

Read the getting started docs, Umbraco and Lit

Setup dev environment, using VS Code

I always had at least 4 tabs open at each step:

  1. The Umbraco documentation
  2. The UI documentation
  3. The Umbraco source code
  4. An Umbraco site running my code

Step 2 - Make my first modal

The first thing I did was create an empty modal.

Keeping it simple, I just want to prove that we can replace the media picker modal.

The only UI it would have was some tabs as they were one of the key differences between the existing modal and mine.

Step 2 - Adding Tabs

How do tabs even work?

I could find them in the UI documentation

Coming from an Angular background, this didn't work as expected. I was expecting passing in models, binding etc

Learning #1

The UI is very bare bones with focus on L&F rather than function

There are differences between the 2 UI documentation sites

https://apidocs.umbraco.com/v15/ui

vs
https://uui.umbraco.com/

(UUI is latest, apidocs lets you pick specific versions of Umbraco)

I ended up looking at the source code for existing UI to figure this out

Step 3
Replacing the existing modal

Try and replace the existing modal

Looking at documentation, we should be able to overwrite existing elements in the manifest.

https://forum.umbraco.com/t/extending-existing-umbraco-backoffice-components/2582/2

This doesn't work...

However a member of the community has been here before me and they've shared their solution

Learning #2

For some system wide modals, you'll have to unregister the existing one and then add your own

Thanks Richard Ockerby for sharing your solution

Success

Step 4 - Add functionality

Now we've proven we can replace the existing modal, can we extend, or pull code out of the Umbraco version.

 

Wasn't able to extend the class, so I started copying code in


This doesn't work as expected, some keys things in the @umbraco-cms/backoffice package are not exposed, or cause issues.

Step 4 - Add functionality

I ended up copying the MediaTreeRepository and all it's dependents into my package, this is not ideal.

 

I also notice that while contexts in the constructor compile, but have errors in the console when running Umbraco. For now I commented them out. fairly certain they're probably doing something import!

Step 5 - Refine the modal

Now I wanted to try and refine the UI.

 

First off I wanted to try and display a media tree with just folders to allow you to pick where you were saving your media.

The current media tree doesn't support that, but perhaps it does in the API.

Step 5 - Refine the modal

There was a promising looking parameter: dataTypeId
But it did not do what I expected

Step 5 - Refine the modal

The current delivery API is just doing exactly what the Backoffice needs and no more, which is understandable. But wouldn't it be nice to have options to extend, filter, override or build on top of what is there.

 

I started to write my own API but thought I'd come back to this. 

Step 6 - Add folder previews

My plan to show previews was to develop my own custom Lit element.

This element would be used when the media item had children (essentially it was a folder). I wanted it to lazy load so it makes a request once the top level stuff had loaded in.

I used the current umb-imaging-thumbnail component as an example.

Step 6 - Add folder previews

This I modifed to load in the children, and then render each child as a thumbnail.

The downside of this is it making 1 additional requests (+1 extra for each image) for each media item that has children. But I'd rather do that then wait for it all to build up before rendering

Step 7 - Debug

Got absolutely stuck trying to get MediaService to work, query parameters were not being set over no matter what I did.

 

I tried copying the media repository, I tried loading it via UmbExtensionManifestInitializer, I tried pulling out my hair

 

In desperation I upgraded Umbraco to v16 (which had just been released). Suddenly it all starts working

Success

In conclusion

Yes it can be done, but in the current state of things, it might take longer than you expect.

Maybe getting a proof of concept running in a week was ambitious.

You'll also have to be willing to make compromises, duplicate code and spend some time being frustrated.

 

 

 

How was the experience?

Mostly one of frustration, but some highs along with the lows. 

I'm actually pretty pleased with what I have, but expected to be much further along.

I'm sure some of this is down to my lack of experience with the tech stack being used, however I'm an experienced dev, with contacts and intimate knowledge of Umbraco, would be much harder for a less experienced, less connected developer.

What can we do?

 

 

 

Let's reduce the learning curve

Umbraco's focus has been on getting feature parity with v13 in the new UI.

We need to get the developer experience for the Umbraco Backoffice into a better place. Please try stuff, and when struggling, ask questions, write blog posts, share examples, raise issues, create PRs and write documentation

However that means they've been creating (technical) debt like an Icelandic bank during a sub-prime mortgage crisis

Issues raised

Here is a list of the issues I've raised as a result of this talk so far, there are a few more coming...


https://github.com/umbraco/Umbraco-CMS/issues/19560

https://github.com/umbraco/Umbraco-CMS/issues/19561

https://github.com/umbraco/Umbraco-CMS/issues/19565

Could we enhance media with AI?

It's 2025, is it even legal to have a tech talk without AI?

  1. Duplicate detection
  2. Tagging and alt tag creation
  3. Backfilling existing media info

Duplicate detection

Simplest form would be just to find items with the same size and filename

Use Azure Vision API to generate a vector for each image which plots each image into a 3D space

We can then do a spatial search and find nearby media items, in theory we can then find different crops of the same image or very similar images

Tagging, Alt tags, descriptions

Use the Azure Vision API to suggest tags, alt, video transcriptions etc

Is this the right place for alt tags? Perhaps it should be possible to override alt tags in the media picker. More contextual

AI will be great at backfilling this data if the package is added later on, and now you want to populate 3000 media items with data

I'm looking for collaborators

I would love to get some of these ideas into Umbraco, either as a package or some bits into core.

Would you like to help?
Speak to me, or get in touch after Codegarden!

Copy of Making the dream a reality

By Steve Temple

Copy of Making the dream a reality

  • 31