Image URL replacement
I am trying to expose some content for a NewsItem for an external application. I would like to return all the content of a news item. I can retrieve the content easy enough, however images look something like this: <img src="[images|OpenAccessDataProvider]80373ee1-f441-6e81-b252-ff0000757d21" />
Is there a quick API where I can pass it a content string and get the content back with the actual URLs replaced?
I have an approach so far but it would be nice if there was something easier (or perhaps more efficient). Currently I do something like this:
1. Retrieve the NewsItems using App.WorkWith().NewsItems().Published().Get()
2. Search through NewItem.Content looking for <img src="[images|OpenAccessDataProvider]...
3. Get the GUID in the SRC attribute.
4. Use the LibraryManager to get the image URL:
LibrariesManager librariesManager = LibrariesManager.GetManager();
Image image = librariesManager.GetImages().Where(i => i.Id == id).FirstOrDefault();
var url = image.MediaUrl;
5. Replace the image src with the URL from the .MediaURL.
Are there any shortcuts to this or any other helper APIs in the SDK?
Hello Gary,
This is the correct approach. The image url in the content of the news Item could be get by parsing the image id and than get the Item and the properties you need.
Regards,
Svetoslav Manchev
Telerik