Correctly resolving Issue 19642

Topics: Troubleshooting
Developer
Apr 24, 2013 at 6:41 PM
https://orchard.codeplex.com/SourceControl/network/forks/StanleyGoldman/Issue19642/contribution/4548

Continuing the linked discussion with Sebastien here...

I understand how intercepting the creation is not ideal here, but I'm looking at current usages of ResizeMediaUrl and MediaUrl and I'm not quite sure how to proceed.

In the core there are a few usages of ResizeMediaUrl..
\src\Orchard.Web\Modules\Orchard.MediaLibrary\Views\Media-Image.Thumbnail.cshtml
<img src="@Display.ResizeMediaUrl(Width: 200, Height: 200, Mode: "crop", Alignment: "middlecenter", Path: media.Resource)" >
The dashboard instructs us to use processed images in our view like such...
@Display.MediaUrl(Profile: "Large", Path: mediaPart.Resource)
To the best of my knowledge these are dynamically created shapes, and the only way to make sure this property exists would be to add IgnoreShapeTracer: true to every invocation.
@Display.MediaUrl(Profile: "Large", Path: mediaPart.Resource, IgnoreShapeTracer: true)
I'm sure that's not ideal either, what should I do?
Coordinator
Apr 24, 2013 at 6:52 PM
The issue is about adding a property named IgnoreShapeTracer in these shapes.

For this, change the methods in the MediaShapes class like this:
ResizeMediaUrl(dynamic Display, TextWriter Output, ContentItem ContentItem, string Path, int Width, int Height, string Mode, string Alignment, string PadColor)
becomes
ResizeMediaUrl(dynamic Shape, dynamic Display, TextWriter Output, ContentItem ContentItem, string Path, int Width, int Height, string Mode, string Alignment, string PadColor)
this way the shape which is rendered is injected as a parameter, so you can change it directly whenever it's been created, so in the method you just have to call
Shape.IgnoreShapeTracer = true;
And you don't need the ShapeTableProvider anymore

do the same for MediaUrl
Developer
Apr 24, 2013 at 6:55 PM
Ahh...

I had the feeling that if I just added that parameter that it would be injected for me...
I just didn't try it.

I will patch it up soon.