1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Thumbnail image for custom user control

Thumbnail image for custom user control

9 posts, 0 answered
  1. Binu
    Binu avatar
    12 posts
    Registered:
    16 Mar 2009
    09 Nov 2009
    Link to this post
    I built a custom view using news module api. Couple of questions related to this:
    1) How to show thumbnail, thumbnail info I can get from the content, but need to resize it. How can I use the image handler to do this?
    2) Whats the best way to get the url to link to actual news item detail?

    Quick response from any gurus appreciated :)
    Thanks
    Binu
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    09 Nov 2009
    Link to this post
    Hi Binu,

    There are four query strings that are available only for image files:

    • width, height -> the strings provide measures and the image is stretched to fit in them. Example:

      http://www.my_domain.com/MyFile.sflb?width=100&height=100

    • decreaseOnly -> when true, the image could only be decreased to fit in the measures set by the width and height strings. Still, if the image is smaller, it would not be enlarged. Example:

      http://www.my_domain.com/MyFile.sflb?decreaseOnly=true&width=100&height=100

    • proportional -> when true (by default), the image is stretched only proportionally until it fits in the measures set by the width and height strings.  Example: 

      http://www.my_domain.com/MyFile.sflb?proportional=true&width=100&height=100  

    If you want to show different data for the Thumbanail - if it is stored in Images and Documents it is IContent object that you can easily access from SetItemMetaData method of NewsView control.

    protected override void SetItemMetadata(System.Web.UI.Control itemContainer, IContent contentItem)
    {
        base.SetItemMetadata(itemContainer, contentItem);
     
        // this will return the ID with the provider name
        // you can get the ID from here and then access the image
        string thumb = (string)contentItem.GetMetaData("Thumbnail");
     
           ....
                ....
    }


    To get the url to link to the actual news item you can call - contentItem.UrlWithExtension. Actually there is no straight forward way to get the full URL beacause the control does not know the page where NewsView control is located. We use relative urls. So you need to build the url. You may find the following post useful - Getting your news articles full url.

    I hope this helps.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Binu
    Binu avatar
    12 posts
    Registered:
    16 Mar 2009
    10 Nov 2009
    Link to this post
    I am using News API
    When I added the news item, I uploaded a thumbnail image, it was saved to /images/myimage.jpg
    <img src="http://www.my_domain.com/myimage.sflb?proportional=true&width=100&height=100" />
    Above markup gives me nothing, pasting that url to browser window gives an error "resource not found"
    Please point out what am I doing wrong here...

    Thanks
    Binu
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    10 Nov 2009
    Link to this post
    Hi Binu,

     As far as I see there is not the library name in the url you posted

    <img src="http://www.my_domain.com/myimage.sflb?proportional=true&width=100&height=100" />

    The link should look like shown below

    <img src="http://www.my_domain.com/images/myimage.sflb?proportional=true&width=100&height=100" />

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Binu
    Binu avatar
    12 posts
    Registered:
    16 Mar 2009
    11 Nov 2009
    Link to this post

    Issue still exist ( i missed /images/ when I typed the post)
    my url is http://www.mysite.org/images/project1.sflb?proportional=true&width=100&height=100

     

    Server Error in '/' Application.

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /images/project1.sflb

     


    Version Information: Microsoft .NET Framework Version:2.0.50727.4016; ASP.NET Version:2.0.50727.4016

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    11 Nov 2009
    Link to this post
    Hi Binu,

    Since even pasting the url throws an error make sure that you have mappings for .ashx extension in your web.config file and IIS

    <add verb="GET" path="*.sflb" type="Telerik.Cms.Engine.ContentHttpHandler, Telerik.Cms.Engine"/>
    <add verb="GET" path="*.sflb.ashx" type="Telerik.Cms.Engine.ContentHttpHandler, Telerik.Cms.Engine"/>


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Binu
    Binu avatar
    12 posts
    Registered:
    16 Mar 2009
    12 Nov 2009
    Link to this post
    Both my config file and IIS has these settings...

    I noticed that if I add image to library, then i can use
    http://www.mysite.org/Libraries/News_Images/project1.sflb?proportional=true&width=100&height=100

    But if I add directly as a thumbnail to a news item, it adds to /images/ folder, and I cannot access using:
    http://www.mysite.org/Images/project1.sflb?proportional=true&width=100&height=100

    So this is not the issue of the hanlder, I am missing something else
    Any clues?

    Thanks
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Nov 2009
    Link to this post
    Hello Binu,

    The parser works only for items uploaded through Images and Documents module. If you have Images folder in your root this could be misleading.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Binu
    Binu avatar
    12 posts
    Registered:
    16 Mar 2009
Register for webinar
9 posts, 0 answered