Announcement

Collapse
No announcement yet.

Giving something back: Hiding Broken Images

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

    Giving something back: Hiding Broken Images

    Hi All,

    Obviously the ideal solution would be not to have broken images in the first place, but in my case, this wasn't always possible.

    Following a healthy discussion, the following is a quick and dirty, but potentially risky from a Search Engine perspective:

    add
    Code:
    onerror="this.style.display = 'none'"
    inside the <IMG> tag of the offending image.

    A better method is to use Actinic's build in PHP functions to check the presence of the file at creation time, thus:

    Code:
    <actinic:block php="true" >
    $rsimage = "rs_" . basename(str_replace('\\','/', '<actinic:variable name="ProductImageFileName" encoding="perl" selectable="false" />'));
    if (file_exists($rsimage)) {
    echo "<img src=\"".$rsimage."\" border=\"0\" width=\"<actinic:variable name="ProductImageWidth" encoding="perl" selectable="false" />\" height=\"<actinic:variable name="ProductImageHeight" />\" alt=\"<actinic:variable name="SectionName" />\" />";
    }
    </actinic:block>
    Last edited by IanSaunders; 05-Aug-2009, 03:14 PM. Reason: Doesn't look like such a great gift now...

    #2
    Caveat - be cautious of using display:none ... this could be perceived as potentially spamming techniques by Google to have page weight but with nothing shown to the user.


    Bikster
    SellerDeck Designs and Responsive Themes

    Comment


      #3
      You'd think Google would simply ignore hidden content, thus robbing spammer of their power. It's a big boy now...

      Good call, though. Is this something I should rethink then? I can't use a server side solution.

      In my case, the image is referenced based on the product image, but in the short term, not all of the images are ready to go up.

      Comment


        #4
        Hiding content from the user is a well know black hat SEO tactic ..... stuff the page with rich keywords and then hide it from view .... your intentions may be honourable but does Google know the difference? Google does ignore the content but kicks you in the shins at the same time for trying to be naughty.


        Bikster
        SellerDeck Designs and Responsive Themes

        Comment


          #5
          Originally posted by IanSaunders View Post
          Ynot all of the images are ready to go up.
          You may be better using the blank.gif as a temp image holder.


          Bikster
          SellerDeck Designs and Responsive Themes

          Comment


            #6
            I'd go with an actinic condition that only adds the img code if there is an image, no need for this then. A blockif checking for null value would be the way forward.

            Gold star for thinking outside of the box though.

            Comment


              #7
              the images in question aren't stored in a variable, so I wouldn't know where to begin generating a condition for this.

              This discussion does give me an idea though - rather than hiding it, could I change the src of the image to a known working one - even a 1px transparent gif?

              Comment


                #8
                Originally posted by IanSaunders View Post
                rather than hiding it, could I change the src of the image to a known working one - even a 1px transparent gif?
                This is the default from-the-box setting!


                Bikster
                SellerDeck Designs and Responsive Themes

                Comment


                  #9
                  Originally posted by leehack View Post
                  Gold star for thinking outside of the box though.
                  Muddy brown star for packing the box with a square wheel!!


                  Bikster
                  SellerDeck Designs and Responsive Themes

                  Comment


                    #10
                    It's all a bit vague what you are trying to do, but that sounds logical although why have things added that are not complete would be the question and why not use variables so you can check them?

                    Comment


                      #11
                      ok...

                      Early in the design of the project, I was requested to add a second image to each product, showing the item in situ. I was advised that for the sake of convenience to the client, they would all be named as per the main image, but with "RS_" prepended to it, making it unnecessary for him to add another filename.

                      Only now, a considerable amount of time later, I've been requested "if there is not a rs_ image entry then don’t display anything".

                      Cue a fair bit of investigation into whether javascript can interrogate a file on a webserver (no / not easily), whether I can incorporate PHP code into the page (I can't make it work), and this, which I found beautifully simple.

                      So yeah, I can see how it appears vague, but it works.

                      And leave my brown star out of this...

                      Comment


                        #12
                        I'd have thought the inbuilt php engine in actinic could evaluate that for you, remember that actinic uses a default image (from site options) if an image is not defined, so it may be as simple as just having an alternative version of that online, just add it into additional files.

                        Comment


                          #13
                          Oh OK.... thinking without a box how about using some PHP to test if the file exists eg:

                          if (file_exists($sThumbImageName)) {


                          Bikster
                          SellerDeck Designs and Responsive Themes

                          Comment


                            #14
                            Take a look at http://www.bikster.co.uk/acatalog/php_snippet.txt which modified normans original thumbnail image generator to test if the file exists (since updated into the KB with no thanks to self )


                            Bikster
                            SellerDeck Designs and Responsive Themes

                            Comment


                              #15
                              Not sure I follow you, but I'm now doing this:

                              Code:
                              <img src="rs_<actinic:block php="true" >echo basename(str_replace('\\','/', '<actinic:variable name="ProductImageFileName" encoding="perl" selectable="false" />'));</actinic:block>"
                              		onerror="this.src = 'transparent.gif'"
                                    border="0"
                                    width="<actinic:variable name="ProductImageWidth" />"
                                    height="<actinic:variable name="ProductImageHeight" />"
                                    alt="<actinic:variable name="SectionName" />" />

                              Comment

                              Working...
                              X