Try our conversational search powered by Generative AI!

Add Tag to an image when create it

Vote:
 

Hi there,

when I create a new image, I pass attributes, categories, status and tags to it.

Attributes and categories are associated correctly, but no Tag is added to my image.

This is the code:

....

Image image = new Image(MyPageHandler.Instance.GetMyPage(CurrentUser).ImageGallery,
"content_" + Session[SessionKey_TempPosterID],
GlobalHelper.Translate("/imagedescription"), new UserAuthor(CurrentUser),
new System.IO.MemoryStream(
Convert.FromBase64String(valueimg.Value.Replace("data:image/jpeg;base64,",
string.Empty))));
image.Status = EntityStatus.Pending;
image.SetAttributeValue("ExternalId", (tempContent as ContData).GetExternalId());

var catSelected = CategoryHandler.Instance.GetCategory(int.Parse(category.SelectedValue));
image.Categories.Add(catSelected);

// **** ADD TAG ***

string currentLanguage="en";

var ImgLocaleTags = TagHandler.Instance.GetPredefinedTags(typeof(EPiServer.Community.ImageGallery.Image), null, null);

foreach(var item in ImgLocaleTags){

if(item.Tag.Name.Equals(currentLanguage))

image.Tags.Add(item.Tag);   //  <==  in debug item.tag but seems that nothing is added to image>

}

// *******

var savedImage = ImageGalleryHandler.Instance.AddImage(image);

...

Any idea?

Thank you.

#117982
Feb 25, 2015 13:21
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.