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

Forums / Developing with Sitefinity / Adding Thumbnails to blog

Adding Thumbnails to blog

43 posts, 0 answered
  1. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    31 Jan 2011
    Link to this post
    Hi,

    Which resx file you  are referring to?

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  2. Iain
    Iain avatar
    26 posts
    Registered:
    29 Dec 2010
    31 Jan 2011
    Link to this post
    The PostNew.ascx.resx in the admin/controltemplates/blogs/app_localresources

    I got to the point Jay Mehta did with the parse error, it was mentioned to edit the resx file, which code should be edited using this threads examples to add a thumbnail image.

    Also does the IIS need to be restarted at any point?
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    31 Jan 2011
    Link to this post
    Hello aaron,

    You can edit the files in Visual Studio without problems. This is a standard ASP.NET resx file. IIS restart is not required.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Ravikant Gaud
    Ravikant Gaud avatar
    8 posts
    Registered:
    21 Apr 2010
    31 Jan 2011
    Link to this post
    Hi,

    I wanted to display a thumbnail image in my blog post, I gone through this post

    Added a meta key in web.config with the name "thumbnail".
    created a .cs file in App_code folder and add below codes in it

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Blogs.WebControls;
    using Telerik.Cms.Engine;
    using System.Web.UI;
    using Telerik.Cms.Web;
    using Telerik.Web;
    using System.Web.UI.WebControls;
     
     
    namespace Telerik.Blogs.WebControls
    {
        public class CustomBlogPost : BlogPosts
        {
            public CustomBlogPost()
            {
     
            }
     
            public override string ItemListTemplatePath
            {
                get
                {
                    return "~/Sitefinity/ControlTemplates/Blogs/ContentViewItemList.ascx";
                }
            }
     
            public override string SingleItemTemplatePath
            {
                get
                {
                    return "~/Sitefinity/ControlTemplates/Blogs/ContentViewSingleItem.ascx";
                }
            }
     
            protected override void SetItemMetadata(Control itemContainer, IContent contentItem)
            {
                base.SetItemMetadata(itemContainer, contentItem);
                foreach (IMetaInfo info in Manager.MetaKeys.Values)
                {
                    Control ctrl = base.FindContentViewControl(info.Key, itemContainer);
                    if ((ctrl != null)
                         && (ctrl is System.Web.UI.WebControls.Image)
                         && (info.ValueType == MetaValueTypes.ShortText))
                    {
                        string imageUrl = (string)contentItem.GetMetaData(info.Key);
                        if (!String.IsNullOrEmpty(imageUrl))
                        {
                            ((System.Web.UI.WebControls.Image)ctrl).ImageUrl = this.GetItemUrl(imageUrl, false);
                        }
                        else
                        {
                            ((System.Web.UI.WebControls.Image)ctrl).Visible = false;
                        }
                    }
                }
            }
     
            private string GetItemUrl(string val, bool resolveAsAbsoluteUrl)
            {
                if (val.StartsWith("~/"))
                    return this.ResolveUrl(val);
     
                if (val.StartsWith("["))
                {
                    int idx = val.IndexOf("]");
                    string provider = val.Substring(1, idx - 1);
                    string strId = val.Substring(idx + 1);
                    Guid id = new Guid(strId);
     
                    if (ContentManager.Providers.ContainsKey(provider))
                    {
                        IContent cnt = ContentManager.Providers[provider].GetContent(id);
                        if (cnt != null)
                            return VirtualPathUtility.ToAbsolute(cnt.UrlWithExtension, this.Context.Request.ApplicationPath);
                    }
                    else
                    {
                        string url = CmsHelper.GetPageUrl(id);
                        if (!string.IsNullOrEmpty(url))
                        {
                            return url;
                        }
                    }
                    return String.Concat("Item not found: [", provider, "]", id);
                }
                return val.ToString();
            }
     
        }
     
    }

    but I not able to display a Image in front end.
    Can you please let me know, what I am missing.

    regards,
    ravikant
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    31 Jan 2011
    Link to this post
    Hello aaron,

    Please check what is returned by GetItemUrl and what parameters you pass to it.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Iain
    Iain avatar
    26 posts
    Registered:
    29 Dec 2010
    31 Jan 2011
    Link to this post
    Hi Ivan,

    Ive added the item Thumbnail to the resx file and added the following code to the ContentMetaFields tag in Blogs/PostNew.aspx

    <asp:Label ID="Label2" AssociatedControlID="Thumbnail" runat="server"><asp:Literal ID="Literal14" runat="server" Text="<%$Resources:Thumbnail %>"></asp:Literal> <em id="ThumbnailLabel" runat="server"></em></asp:Label>
        <asp:TextBox ID="Thumbnail" Text="" runat="server" MaxLength="250"></asp:TextBox>
        <sfLib:ButtonSelector WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx" AssociatedControls="Thumbnail" runat="server" cssclass="pickerWrapper" ButtonText="<%$Resources:Select%>" />
        <p class="example">
       <asp:Literal ID="Literal15" runat="server" Text="<%$Resources:ThumbnailNote %>"></asp:Literal>
       </p>

     and Im now receiving this error:


    Parser Error Message: Unknown server tag 'sfLib:ButtonSelector'.

    Source Error:

    Line 264:                    <asp:Label ID="Label3" AssociatedControlID="Thumbnail" runat="server"><asp:Literal ID="Literal14" runat="server" Text="<%$Resources:Thumbnail %>"></asp:Literal> <em id="ThumbnailLabel" runat="server"></em></asp:Label>
    Line 265:    <asp:TextBox ID="Thumbnail" Text="" runat="server" MaxLength="250"></asp:TextBox>
    Line 266:    <sfLib:ButtonSelector WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx" AssociatedControls="Thumbnail" runat="server" cssclass="pickerWrapper" ButtonText="<%$Resources:Select%>" />
    Line 267:    <p class="example">
    Line 268:   <asp:Literal ID="Literal15" runat="server" Text="<%$Resources:ThumbnailNote %>"></asp:Literal>

    Also is this whole process posible without recompiling the code?
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    31 Jan 2011
    Link to this post
    Hi,

    Please make sure that you have registered TagPrefix for sfLib. This is a general ASP.NET error.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Iain
    Iain avatar
    26 posts
    Registered:
    29 Dec 2010
    03 Feb 2011
    Link to this post
    Would of been helpful to mention this line of code in the snippet at the top of this tread

    <%@ Register TagPrefix="sfLib" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %>

    So I have the thumbnail in the blog postnew and postedit template and this field is updated correctly in the back end... but when displaying this in the contentViewItemList template the <img> src attribute is blank?

    What have I missed?
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Feb 2011
    Link to this post
    Hi,

    Does the meta key gets saved when you Edit, Create the item. You should see this in preview mode. If the item is not saved

    1. It is not defined in the web.config
    2. You have not added the ButtonSelector inside ContentMetaFields control and you are not using ITextControl to persist the metakey value.

    Another option is that you are not resolving the value returned by the selector on the public part of the website. If the value is dynamic link you have to use GetItemUrl method listed above.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Iain
    Iain avatar
    26 posts
    Registered:
    29 Dec 2010
    03 Feb 2011
    Link to this post
    The data is saved and visible through the preview.

    I also added a summary field using the same technique and this appears correct, so I guess this is not resolving the URL, where should the code be placed? Can it be placed in a code block rather than within a .cs file?
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Feb 2011
    Link to this post
    Hi,

    You can use code block in the template, but it is better to use the custom control provided above.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Iain
    Iain avatar
    26 posts
    Registered:
    29 Dec 2010
    03 Feb 2011
    Link to this post
    Is there a solution example in the code libraries as I dont seem to be getting anywhere


    Grrr....!
  13. Iain
    Iain avatar
    26 posts
    Registered:
    29 Dec 2010
    23 Feb 2011
    Link to this post
    Hi Ivan,

    After retracing my steps I have made some small progress. I wasnt able to create a custom class but was able to get the thumbnail data from the metafields into the control template (Sitefinity\ControlTemplates\Blogs\ContentViewItemList.aspx) , the thumbnail data is held as "~images/Thumb1.jpg".

    I can display this fine as a literal in the template but am unable to use this to display an image?

    Any suggestions for an amateur?


    Cheers


    Iain
Register for webinar
43 posts, 0 answered
1 2