none
How to Show images in slide show with description in the below of the image if exist. RRS feed

  • Question

  • How to Show images in slide show with description in the below of the image if exist.

    I have a div with class(background black color).inside there is a code for description to add it to every image if exist in the properties.

    Default i am showing top 12 images form the library.

    Requirement is want to hide description div if description doesn't exist to even single image.

    Or

    i have to show description block to images only if any one of the image having Description metadata.Otherwise have to hide it.

    Could you please help?

    I am providing my .ascx design below.

    <div class="slideshow">
                <asp:Repeater ID="repslide" runat="server">
                    <ItemTemplate>
                        <div class="item">
                            <img class="img-responsive" src='<%# ((Entities.Image)(Container.DataItem)).Url %>?ID=10'>
                            <div class="Desc-caption ">
                                <%# ((Entities.Image)(Container.DataItem)).Description == null? ((Entities.Image)(Container.DataItem)).Description : ((Entities.Image)(Container.DataItem)).Description.Length >=200? ((Entities.Image)(Container.DataItem)).Description.Substring(0,200)+"..." : ((Entities.Image)(Container.DataItem)).Description %>
                            </div>
                        </div>
                    </ItemTemplate>
                </asp:Repeater>
            </div>


    Friday, May 24, 2019 6:55 AM

All replies

  • Hi,

    You could add dynamic CSS for description div/item, if description is empty, hide it.

    Sample code:

    <div class="<%# ((Entities.Image)(Container.DataItem)).Description.Length != 0 ? "Desc-caption" : "Desc-Hide" %>">
    .Desc-Hide{
    display:none;
    }

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, May 27, 2019 2:50 AM