November Happy Hour will be moved to Thursday December 5th.

Add Image to Blog Entry - Image Gallery is null

Vote:
 

I'm working with Community in EPiServer 7.5. I'm trying to add an image to a blog entry. This is the code

  stream.Position = 0;
                    // Create a image and set the presentation name of the user as name of image                                    
                    EPiServer.Community.ImageGallery.Image presentationImage =
                        new EPiServer.Community.ImageGallery.Image(entry.ImageGallery, FileName,
                            FileName, CurrentBlog.Author, stream);

                    // Add the image to the system
                    presentationImage = ImageGalleryHandler.Instance.AddImage(presentationImage);

                    // Set the image to presentation image
                    entry.SetAttributeValue(BlogAttributes.PresentationImage, presentationImage);

But it falls over at 

ImageGalleryHandler.Instance.AddImage(presentationImage);

with a null exception - it looks like the image gallery associated with the blog entry hasn't been created

Can anyone help please




#88231
Jul 07, 2014 13:44
Vote:
 

The error is

Value cannot be null.
Parameter name: image.ImageGallery

I can't see how this is created. If I reflect out the dll it should be loaded from the owned object collection

The image gallery can be assigned to directly because it is read only.

Can anyone help?

(PS - Moan - but I'm astonished how difficult it is to add an image to a blog entry. I would have thought this was a really standard requirement for a community tool. Moan over)

#88233
Jul 07, 2014 14:05
Vote:
 

Actually I've changed tack with this

Image inserted with the normal images

Content Reference ID stored as an attribute against this blog entry

Image can be retrieved based on that content reference

Forget all notions of image galleries

#88237
Jul 07, 2014 16:41
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.