private static readonly UmbracoHelper UmbracoHelper = new UmbracoHelper(UmbracoContext.Current);
then
To get image url I use
public static string GetMediaPickerUrl(IPublishedContent content, string imageField)
{
var imageUrl = string.Empty;
try
{
if (content.HasValue(imageField))
{
var mediaItem = UmbracoHelper.TypedMedia(content.GetPropertyValue
but when i get api on postman the image_url is still not updated,
Refresh UmbracoContext
I have updated the db into cmsPropertyData table,
but when i get api on postman the result is still not updated,
Is it because I do not refresh the UmbracoContext?
Hi Nguyen
What api did you mean? Can you share the code of api?
ContentService is working directly with database - you have to use it in API then all data will be fresh and latest
/Alex
Firstly
private static readonly UmbracoHelper UmbracoHelper = new UmbracoHelper(UmbracoContext.Current);
then To get image url I use
public static string GetMediaPickerUrl(IPublishedContent content, string imageField) { var imageUrl = string.Empty; try { if (content.HasValue(imageField)) { var mediaItem = UmbracoHelper.TypedMedia(content.GetPropertyValue
but when i get api on postman the image_url is still not updated,Hi,
I would recommend you to read the common pitfalls of Umbraco.
https://our.umbraco.org/documentation/reference/Common-Pitfalls/
Its not recommended to use static for the UmbracoHelper.
Thanks Garðar, you are right, it's much better to make an extension method for Umbraco helper.
Hi
By the way, how did you update cmsPropertyData table?
You have to publish changes with this method: ApplicationContext.Current.Services.ContentService.SaveAndPublishWithStatus(content);
Alex
Thanks Alex, that right.
I want to update image_url,
so I used sql query to update the db.
You have no way to use ParentContetn.SetValue to update the image url, I already have imageid
is working on a reply...