Announcement

Collapse
No announcement yet.

If link contains .jpg add class

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    If link contains .jpg add class

    I am sure I have asked this in the past and had it answered but I cannot find it!

    Client uses 'Simple :Link' in product details to let the viewer click on a link to view an image.

    Click image for larger version

Name:	imagealink.jpg
Views:	99
Size:	44.6 KB
ID:	555967
    I would like a bit of script that where 'ProductLinkInfo' contains .jpg a class is added to the 'a' tag.

    Thank you and apologies for possible duplication
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

    #2
    Found it!

    Does link contain an image:

    Code:
    <div id="home" class="tab-pane fade in active show">
    <h3>Product Description</h3>
    <script>
    $(function() {
    $('.active.show a[href$=".jpg"],.active.show a[href$=".JPG"], .active.show a[src$=".gif"], .active.show a[src$=".png"]').addClass("fancybox");
    $('.active.show a[href$=".jpg"],.active.show a[href$=".JPG"], .active.show a[src$=".gif"], .active.show a[src$=".png"]').attr('id', 'mzpd-<actinic:variable name="EncodedProductAnchor" />');
    $('.active.show a[href$=".jpg"],.active.show a[href$=".JPG"], .active.show a[src$=".gif"], .active.show a[src$=".png"]').attr('data-fancybox','gallery-<actinic:variable name="EncodedProductAnchor" />');
    });
    </script>
    <p><actinic:variable encoding="actinic" name="ProductDescription" /></p>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22FileURLNotEmpty%22%20%2f%3e" >
    
    <script>
    $(function() {
    $('.product-text a[href$=".jpg"],.product-text a[href$=".JPG"], .product-text a[src$=".gif"], .product-text a[src$=".png"]').addClass("fancybox");
    $('.product-text a[href$=".jpg"],.product-text a[href$=".JPG"], .product-text a[src$=".gif"], .product-text a[src$=".png"]').attr('id', 'mzpt-<actinic:variable name="EncodedProductAnchor" />');
    $('.product-text a[href$=".jpg"],.product-text a[href$=".JPG"], .product-text a[src$=".gif"], .product-text a[src$=".png"]').attr('data-fancybox','gallery-<actinic:variable name="EncodedProductAnchor" />');
    });
    </script>
    
    <p class="product-text"><a href="<actinic:variable name="ProductLinkInfo" />"><strong><actinic:variable encoding="actinic" name="ProductLinkText" /></strong></a></p>
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

    Comment


      #3
      You can use a regular expression in a BlockIf. Here's your original request done in a single line:
      Code:
      <a href="<actinic:variable name="ProductLinkInfo" />"<actinic:block if="preg%5fmatch%28%22%2f%2ejpg%24%2fi%22,%20%3cactinic%3avariable%20name%3d%22ProductLinkInfo%22%20%2f%3e%29"> class="fancybox"</actinic:block>>
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Awesome. Thank you so much Norman.
        Jonathan Chappell
        Website Designer
        SellerDeck Website Designer
        Actinic to SellerDeck upgrades
        Graphicz Limited - www.graphicz.co.uk

        Comment

        Working...
        X