Announcement

Collapse
No announcement yet.

Using php to generate a new image filename ????

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

    Using php to generate a new image filename ????

    This should be easy, and I've looked at this similar thread here https://community.sellerdeck.com/for...ag, but I can't for the life of me get it to work.

    To reduce my image size for page loading times I've created a number of small images for mega-menu that have an 's-' prefix to the section image filename specified in sellerdeck. i.e. 'gizmo.jpg' has a smaller image for megamenu named 's-gizmo.jpg'

    What I'm trying to do is get sellerdeck to generate the new filename automatically in the megamenu layout but I just can't get it to work. After getting fed up of uploading all the time I've been trying to just get the right text in the variable and use it in the 'title' for the image so I can at least see it working in preview mode but whatever I do I can't get sellerdeck to create a simple bit of text 's-imagename.jpg'

    I've tried sectionimagefilename, sectionimagefilenameraw, basename around both, stripping out the extra bits using strings. Nothing seems to work.

    Anyone know how to do this? I've been at it all day!
    -----------------------------------------

    First Tackle - Fly Fishing and Game Angling

    -----------------------------------------

    #2
    I might be getting there. This seems to work, at least in the 'title' tag.

    PHP Code:
    $mymenuimage 's-'.basename(str_replace('\\''/''<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />')); 
    -----------------------------------------

    First Tackle - Fly Fishing and Game Angling

    -----------------------------------------

    Comment


      #3
      So that does work. Both in preview mode and online. All I had to do is replace 'SectionImageFileName' in the line of php that generates the $ListHeader in megamenu with '.$mymenuimage.'
      -----------------------------------------

      First Tackle - Fly Fishing and Game Angling

      -----------------------------------------

      Comment


        #4
        Test it in Preview when the images are in a sub-folder of the site folder.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          I think I know what you're saying but I deliberately put all my 's-' images in the site folder rather than a sub folder to avoid any problems.

          I did write my php so I could generate a different value for preview and notpreview modes but haven't had to use it that way. It would allow me to use a prefix that included an image subfolder if I needed to for the preview mode.

          i.e my actual code is

          PHP Code:
          <actinic:block if="%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e" >
          $mymenuimage 's-'.basename(str_replace('\\''/''<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />'));
          </
          actinic:block>
          <
          actinic:block if="%3cactinic%3avariable%20name%3d%22IsNotPreviewMode%22%20%2f%3e" >
          $mymenuimage 's-'.basename(str_replace('\\''/''<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />'));
          </
          actinic:block
          -----------------------------------------

          First Tackle - Fly Fishing and Game Angling

          -----------------------------------------

          Comment


            #6
            With over 200 images in my megamenu and each one dropping from 40-50 KB to under 1KB this has saved me around 1MB of image loading on the page.
            -----------------------------------------

            First Tackle - Fly Fishing and Game Angling

            -----------------------------------------

            Comment


              #7
              That works well. If you want to keep your Site folder tidy, you could move the small images to a sub-folder "SmallImages" and use:
              Code:
              $mymenuimage = 'SmallImages/s-'.basename(str_replace('\\', '/', '<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />'));
              And there will be no need for BlockIf's.
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                Good Point. I'll tidy up my code and images tomorrow. I'm glad to have this finally sorted but I think it's a worthwhile thing to have done.
                -----------------------------------------

                First Tackle - Fly Fishing and Game Angling

                -----------------------------------------

                Comment

                Working...
                X