Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi to everyone ... to remove media from node and from Media i use
mediaService.Delete(media , 0); content.SetValue("image", ""); contentService.SaveAndPublish(content, userId: 0);
it seems like ok, but you will get error here :
string img = Model.HasValue("image") ? Model.MediaById(Model.GetProperty("image")).Value).umbracoFile : "";
The result of HasValue is true!! .. the error you will get is "Object reference not set to an instance of an object." .
but when adding this line you will not get any errors :
umbraco.library.RefreshContent();
In other hand if i use MoveToRecycleBin() instead of Delete(), here we no need to use "umbraco.library.RefreshContent();" .
mediaService.MoveToRecycleBin(media , 0); content.SetValue("image", ""); contentService.SaveAndPublish(content, userId: 0);
so the Delete(media) should use refrechContent(), but MoveToRecycleBin(media) no need to use refrechContent().
for a good performance:
Note : umbraco version is 6.2.4
thanx ..
Hi Khaled,
Try to use something like that:
content.SetValue("image", null);
"" - is just empty string value.
Thanks
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
For Better Performance Delete(media) Or MoveToRecycleBin(media)
Hi to everyone ...
to remove media from node and from Media i use
it seems like ok, but you will get error here :
The result of HasValue is true!! .. the error you will get is "Object reference not set to an instance of an object." .
but when adding this line you will not get any errors :
In other hand if i use MoveToRecycleBin() instead of Delete(), here we no need to use "umbraco.library.RefreshContent();" .
so the Delete(media) should use refrechContent(), but MoveToRecycleBin(media) no need to use refrechContent().
for a good performance:
Note : umbraco version is 6.2.4
thanx ..
Hi Khaled,
Try to use something like that:
"" - is just empty string value.
Thanks
is working on a reply...