Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, March 11, 2013 10:09 AM
I have attached a picture to the list item and then when I click the item, there is a link of the attachment but not the picture graphics! I want to display the picture on the list item page and how to do it?
I am a beginner of SharePoint 2010 and my English is not very good! Thanks!
All replies (4)
Monday, March 11, 2013 11:33 AM âś…Answered | 1 vote
Hi,
Using few easy steps you can set image in your out of the box List View, Edit and View Item Page.
1. Create one Picture type Column in your list.
2. Just create one Event Handler with Item
/// <summary>
/// An attachment was added to the item.
/// </summary>
public override void ItemAttachmentAdded(SPItemEventProperties properties)
{
base.ItemAttachmentAdded(properties);
SPListItem item = properties.ListItem;
//SPAttachmentCollection attach = item.Attachments;
string attachmentUrl = item.Attachments.UrlPrefix + item.Attachments[0];
item["PictureColumnName"] = attachmentUrl;
item.Update();
}
Now, just add item with attachment and you will see attached image in Picture Column field.
Manoj | SharePoint
Monday, March 11, 2013 10:18 AM
This is not possible in OOTB. if you want to display attached image, need to customize Edit and Display item forms with the help jquery you can display the image.
The other way around is you can user image column instead attachment, the image column is OOTB field. If you want to try this, below are the steps.
1. Create a site column and the type is "Image with formatting and constraints for publishing"
2. Add this column in you list content type(Enable allow content type then add this column in to list content type)
3. Now upload the image then view it in Edit and in Display forms.
Note: The uploaded images resides on a SharePoint library(that is selected while uploading the image)
Hope this will help you.
Senthilrajan Kaliyaperumal
Wednesday, March 13, 2013 9:26 AM
Great! Thanks a lot!
Tuesday, March 31, 2015 3:14 AM | 2 votes
Can you tell me if this will work for Office 365? If so, how do I create an event handler?
Thanks!