How to get tcm id like multimedia, say jpg from Tridion via Core Service?

In Tridion, there are several types of media in the administration folder. I want to write a method that returns the tcm identifier for a given mime type, for example. for the gif mime type, it should return "tcm: 0-1-65544".

Can anyone think of this?

+7
source share
2 answers

You can simply get a list of all types of media, and then choose the one you need:

var mmType = ClientAdmin.GetSystemWideList(new MultimediaTypesFilterData()).Single(mt => ((MultimediaTypeData)mt).MimeType == "image/jpeg"); 
+3
source

Each scheme has the AllowedMultimediaTypes property, which returns a list, and the default scheme for multimedia messages is usually configured for all types. If it does not allow all types, then for this purpose you can create a special scheme.

So, all you have to do is get the allowed media types by default media scheme (or your special scheme that allows all types), and then map the entered mime type to the mimetime of each returned MultimediaType.

Here is an example above (not verified):

 Schema defaultMMSchema = (Schema)engine.GetObject("Your-Default-MMSchema-WebDav-Path"); IList<MultimediaType> mmTypes = defaultMMSchema.AllowedMultimediaTypes; foreach(MultimediaType mt in mmTypes) { switch(mt.MimeType) { case "jpg": ... } } 

Alternatively, the TCM identifiers from the predefined media types are persistent, so you don’t have to worry about them changing after the content is transferred to another environment. Therefore, you can write a class that provides a mime type mapping with the tcm identifier. Note. It’s not so elegant if you create your own element types, since you will need to update your code with the TCM ID for each Tridion environment.

+4
source

All Articles