I have a custom module with a long Text field, named Logo. It contains a single Image and other HTML. I want to display the logo image on the page, so I just assign the value to a literal, ("myCompany" is of type DynamicContent).
The result displays this HTML on the page:
Any help is appreciated.
Going to make this a two part question, the first above. Basically how do you pull a long Text field from a custom module and displaying as HTML so that all images show up that are embedded?
Second - in looking at my custom module I added a Media field named logo that holds the company logo instead. The block below works to pull this data. Is this the correct/most efficient way to pull an image from a custom module?
Regarding your questions:
Long Text field
I think you should use the LinkParser to get the right html from your text field. You can use it like this:
It has some more overloads, if you need them.
Getting an image
Your code is fine. You could make it a bit smaller like this:
Sorry, for this last code to work, you will need an extension method.
Just put this method in a static class, named e.g. 'Extensions':