Announcement

Collapse
No announcement yet.

CUSTOM PHP Related Product Image Thumnail issue

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

    CUSTOM PHP Related Product Image Thumnail issue

    Hi all,

    I am having some very frustrating issues with product thumbnails. The site is quite custom and it uses ProductThumbnailImageFileName.

    All the images and data is managed by an external access database.

    OK - firstly this page is working fine with ProductThumbnailImageFileName.

    However, on a product page it doesn't work so well. It seems to be missing out the new images I have added recently. This is not however because of the "new" product heart indicator, this is simply an overlaid image in .css controled by a blockif in actinic. I have tested thoroughly with and without.

    HOWEVER it does seem to only happen to new products that I have added recently. The product related bit is generated by the PHP which someone did on this forum, shown below - again controlled by blockifs in a customized productlayout.

    Code:
    <h4>Products you may also like</h4>
    
    <!-- Here we fill a PHP array with snippets of HTML from all products -->
    <actinic:block php="true" >unset($allproducts);</actinic:block>
    <actinic:block type="EntireSectionList">
    <actinic:block type="ProductList" php="true">
    <actinic:block if="%3cactinic%3avariable%20name%3d%2295danishBrand%22%20%2f%3e%20%3d%3d%20%22Eva%20Solo%22%20AND%20%3cactinic%3avariable%20name%3d%22Category1%22%20%2f%3e%20%21%3d%20%22Spare%20Part%22" >
    
    
    	
    
    
    if ( <actinic:variable name="ProductType" /> == 0 )
    {
    $allproducts[] = <<<ENDOFCODE
    
    <actinic:variable name="ProductLayout" />
    
    ENDOFCODE;
    }
    </actinic:block>
    </actinic:block>
    </actinic:block>
    
    
    <div class="podwrap fixclear">
    <!-- Here we output 5 random products -->
    <actinic:block php="true" >
    
    for ( $i=1; $i<=5; $i++ )
    {
    echo '' . $allproducts[mt_rand(0, count($allproducts) - 1)];
    }
    
    
    </actinic:block>
    </div>
    If you go to page sourceand search for "Vacuum jug black" the a href is being outputted fine, but the image has outputted incorrectly, as "CutOuts\Eva SoloB941_Thumb.jpg" The image is actually in CutOuts\Eva Solo\ on my pc. The image is named 501021_Thumb.jpg and is on the server. The image not found error is also on my local machine.

    The image path in my database is exactly the same as every other product on my site, both working and not working - I am not sure why it is being shown as \ not / but as you can see in the view source the ones working seem to have worked fine.

    I have tried:
    Resaving all images to remove any bugs
    Reapplying the linking to the database
    Compacting and repairing the database
    Matching my database fields and layouts against working product
    Going into the product manually and selecting the file type

    I did managed to get the images displaying properly when removing the actinic variable which pulls in the ThumbnailImageFileName by putting in the actual path to a current working image...Not sure if this helps or not.

    Spent about 5 hours trying to fix this today and I am losing my mind! Really hope someone can help...

    Thanks

    Gordon

    #2
    Looks like you're being messed up by a PHP heredoc quirk. Various things after a backslash can be interpreted as escapable: I.E.
    Code:
    If the string is enclosed in double-quotes ("), PHP will interpret more escape sequences for special characters: 
    
    Escaped characters Sequence Meaning 
    \n linefeed (LF or 0x0A (10) in ASCII) 
    \r carriage return (CR or 0x0D (13) in ASCII) 
    \t horizontal tab (HT or 0x09 (9) in ASCII) 
    \v vertical tab (VT or 0x0B (11) in ASCII) (since PHP 5.2.5) 
    \f form feed (FF or 0x0C (12) in ASCII) (since PHP 5.2.5) 
    \\ backslash 
    \$ dollar sign 
    \" double-quote 
    \[0-7]{1,3} the sequence of characters matching the regular expression is a character in octal notation  
    \x[0-9A-Fa-f]{1,2} the sequence of characters matching the regular expression is a character in hexadecimal notation  
    
    As in single quoted strings, escaping any other character will result in the backslash being printed too.
    So your \501021_Thumb.jpg will be seen as starting some sort of octal notation character.

    Try replacing all \ in file-names with / instead.

    In whatever Layout loads the product thumbnail image, replace:
    Code:
    <actinic:variable name="ThumbnailImageFileName" />
    With:
    Code:
    <actinic:block php="true">echo str_replace('\\', '/', '<actinic:variable name="ThumbnailImageFileName" encoding="perl" selectable="false" />');</actinic:block>
    N.B. Not at SD system right now so code my have typos.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Hi Norman,

      Thank you very much - worked a treat. All now sorted!

      Thanks again,

      G

      Comment

      Working...
      X