Announcement

Collapse
No announcement yet.

php image resize method - can you remove folder from filename?

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

    php image resize method - can you remove folder from filename?

    Hi Guys,
    Working on a site with loads of products and sensibly (from an organising point of view) Product images have been organised into folders and sub folders within the site1 folder.

    Using the php resizing methods developed by Norman and similar developments by Jont : http://community.actinic.com/showthread.php?t=34654

    Is there a way of generating the smaller images and then referencing them using something like...

    <img src="new_foldername/prefix-<actinic:variable name="ProductImageFileName" />" alt="<actinic:variable name="ProductName" />" />
    ....without the previous sub folders/directories of the original images being included in the ProductImageFileName? I can't seem to do it. Is there another way? My thumbnails image names generate with perfect prefix but then include directory names/sub names/ etc within the final image name.

    p.s I also need this to work for extendinfo images and images being brought in using custom variables (just in case actinic would treat these any different variable names not withstanding).

    Having all the images in the site 1 folder directly just ain't an option as it would be impossible to naivigate (though all the image directories are sub directories of the site1 folder).

    Any help would be gratefully recieved even if it is a ..no chance kind of a reply.
    Cheers
    Bangers
    Boxhedge New Media Design
    Design and development solutions for SME's.
    Tel: 0118 966 2786
    Examples of work can be found at http://www.boxhedge.com

    #2
    PHP's basename function will fix this. E.g.
    Code:
    <actinic:block php="true">echo basename(str_replace('\\','/', '<actinic:variable name="ProductImageFileName" encoding="perl" selectable="false" />'));</actinic:block>
    And the str_replace deals with some quirks in passing Windows filenames into PHP.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      If using V10, then for Extended Info Images, use the above with ExtendedInfoImageFileNameRaw instead of the usual extended info image filename.
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Hi Norman,
        Thanks for the reply this was great advice and certainly pointed me to a solution. I found your method removed the / / between the directory names but still left their names i the product image name however because I could see the logic I managed to find this elsewhere on t'internet and adapted for actinic, works a treat when used to replace the imagesfilename in and img tag.
        Instead of standard reference method:
        <img src="directory_name/prefix_<actinic:variable name="ProductImageFileName" encoding="perl" selectable="false" />" alt="<actinic:variable name="ProductName" />" />
        Using this php replacement method removes directories before the filename:
        <img src="directory_name/prefix_<actinic:block php="true" >$path_parts = pathinfo('<actinic:variable name="ProductImageFileName" encoding="perl" selectable="false" />');echo $path_parts['basename'], "\n";</actinic:block>" alt="<actinic:variable name="ProductName" />" />
        It's a life saver, thanks Norman.

        p.s
        If using V10, then for Extended Info Images, use the above with ExtendedInfoImageFileNameRaw instead of the usual extended info image filename.
        I'm not on this project (using v9 unfortuneately). Am I right in thinking you'd suggest this if I could to remove an actinic "quirk" that produces errors on image creation from ExtendInfoImage? Is there another way around it in v9 (could ExtendedInfoImageFileNameRaw be created by manually adding a new condition?)

        Thnaks again
        Bangers
        Boxhedge New Media Design
        Design and development solutions for SME's.
        Tel: 0118 966 2786
        Examples of work can be found at http://www.boxhedge.com

        Comment


          #5
          ExtendedInfoImageFileNameRaw cannot be created by database tweaking. Needs V10.

          Other bits answered on your other thread.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment

          Working...
          X