locked
show images from library inside the webpart RRS feed

  • Question

  • Hi,

    I have a image library to upload images and i have a webpart to show these images in the library.But my problem is when i fetch images from the library the image url is only displayed and the actual image is not displayed.

    Wat should i do to display the image in the <img> tag?


    Root1234

    Monday, July 30, 2012 3:25 PM

Answers

  • hi,

    By giving this the image url is not shown.

    can u pls help.


    Root1234

    Check url in Internet Explorer Developer Panel (F12) and correct your code accordingly.

    My contributions: SharePoint 2010 Solution Installer

    • Marked as answer by Lhan Han Monday, August 6, 2012 8:33 AM
    Tuesday, July 31, 2012 7:51 AM

All replies

  • Well,

    1) Just create a view of your picture library which displays the image preview/Image. Further in your list web part just use that view

    OR

    2) if you want to display the images with content, then just use normal HTML image tag with src pointing to image URL.


    Ashish Ranjan (Please click "Marked As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you)

    Monday, July 30, 2012 3:47 PM
  • hi

    I use just html image tag to display the image like

    li.Value = "<img src=\"" + SPContext.Current.Site.Url+imgItem.File.ServerRelativeUrl.ToString() + "\">";

    but this returns the full url of the image inside my webpart if i copy the url and paste on a browser i get the image but inside my webpart it is not shown?how to do this?


    Root1234

    Monday, July 30, 2012 3:58 PM
  • hi sooraj
    Image img = new Image();
                img.ImageUrl = "your IMGURL";
                this.Controls.Add(img);

    yaşamak bir eylemdir

    • Proposed as answer by Aviw_ Monday, July 30, 2012 6:09 PM
    Monday, July 30, 2012 4:13 PM
  • hi

    I use just html image tag to display the image like

    li.Value = "<img src=\"" + SPContext.Current.Site.Url+imgItem.File.ServerRelativeUrl.ToString() + "\">";

    but this returns the full url of the image inside my webpart if i copy the url and paste on a browser i get the image but inside my webpart it is not shown?how to do this?


    Root1234

    Hello!

    I think you forgot about closing tag:

    </img>
    or
    li.Value = string.Format("<img src=\"{0}{1}\" />", SPContext.Current.Site.Url, imgItem.File.ServerRelativeUrl.ToString());

    My contributions: SharePoint 2010 Solution Installer

    Monday, July 30, 2012 6:13 PM
  • hi,

    By giving this the image url is not shown.

    can u pls help.


    Root1234

    Tuesday, July 31, 2012 4:35 AM
  • hi,

    By giving this the image url is not shown.

    can u pls help.


    Root1234

    Check url in Internet Explorer Developer Panel (F12) and correct your code accordingly.

    My contributions: SharePoint 2010 Solution Installer

    • Marked as answer by Lhan Han Monday, August 6, 2012 8:33 AM
    Tuesday, July 31, 2012 7:51 AM