How can we save multimedia components using external resource types if the URL doesn’t end in with a file extension?
Asked Answered
P

2

9

We have a Tridion use case related to curated content where we are creating multimedia components for images associated with our content which are pointing to External resource types instead of uploaded resource types.

One of the issues we have run into with this use case is that despite explicitly setting the Multimedia Type for the resource, if the URL of the image has either a query string in it: http://cdn.hw.net/UploadService/1c8b7f28-bb12-4e02-b888-388fdff5836e.jpg?w=160&h=120&mode=crop&404=default or uses a ‘friendly url’: http://www.somewhere.com/images/myimage/ when we save the component, Tridion barfs with error messages similar to : ‘Invalid value for property 'Filename'. Unexpected file extension: jpg?w=160&h=120&mode=crop&404=default. Expecting: jpg,jpeg,jpe.’

So far, the only way we’ve been able to figure out to potentially get around this issue is to do something hacky like appending an extra query string parameter to the very end of the urls which end with the expected file extension: http://cdn.hw.net/UploadService/1c8b7f28-bb12-4e02-b888-388fdff5836e.jpg?w=160&h=120&mode=crop&404=default&ext=.jpg Obviously, this is not the best solution and in fact may not work for some images if the site they are being served from strictly validates the requested URL.

Does anyone have any ideas on how we can work around this issue?

Perception answered 19/2, 2013 at 19:11 Comment(0)
P
9

Unfortunately I can't really think of an easy solution to this, since Tridion "detects" the Mime type by checking the file extension.

You could perhaps add it while saving and remove it when reading (via Event System)? Definitely a worthwhile enhancement request, to my knowledge this behavior has not been changed for the soon-coming Tridion 2013... See comment below, it has been changed for 2013.

Perceval answered 19/2, 2013 at 19:35 Comment(3)
It is changed, there will be a solution in 2013Backandforth
Good idea on using the event system to deal with this behind the scene and good to know about the direct support for this in Tridion 2013.Perception
Is there any solution in 2013, We are using 2013 sp1 but still the same problemRage
L
8

+1 for Nuno's answer. Recognizing that the title of your question is specific to multimedia components, you may want to consider another approach which is to use normal Components, not Multimedia Components. You can create a normal component schema called something like "External Image" that has an External Url field to store your extentionless url.

Content authors will then include these images via regular component linking mechanisms in the Tridion GUI.

You will then need a custom link resolver TBB that will parse the Output item (via Regex) looking for any Tridion anchor tags <a tridion:href="tcm:x-y-z"> and for each one replace them with an <img src=...> tag where the src path would come from this linked component.

For an example of a similar approach, but with videos, and sample code for a custom link resolver TBB have a look at the code in the following post: http://www.tridiondeveloper.com/integration-sdl-tridion-jw-media-player.

Lathing answered 19/2, 2013 at 19:58 Comment(1)
Really good idea. As it stands now, we are trying to use the same schemas for creating curated content we use for our original content (which uses uploaded multi-media components) as alot of our component/page templates 'just work' if we do that. Although I think in the short term we'll do as Nuno suggests, your answer has me rethinking the decision to handle images for this content in the exact same way we do for other content and also provides a solution for an upcoming project we have (ironically related to videos.)Perception

© 2022 - 2024 — McMap. All rights reserved.