1

I have included a PHP script in a Typo3 site. This PHP script genereates the img tags, which is automatically taken as base for the imageflow-slider.

The imageflow files are in the folder /fileadmin/teamtemplate. The images in /fileadmin/teamtemplate/images.

In the imageflow.js I have the following parameters:

this.defaults =
{
    imagePath:          '',                                    /* Path to the images relative to the reflect_.php script */
    reflectPath:        'fileadmin/teamtemplate/',             /* Path to the reflect_.php script */

In the output of the html-file I have the following:

  img  src="./images/1317986502.png" ongdesc="" width="380" height="253" alt="" />

(Sorry, but I didn't found out how to post HTML code.) Imageflow creates the following path, which is working:

fileadmin/teamtemplate/reflect3.php?img=./images/1317986502.png

The problem is the following:

For the reflect3.php the path is correct, because (./images) is accessible:

-reflect3.php
-images/
--1317986502.png

Imageflow generally takes the URL given in the html img src tag. reflect3.php can now access the images, but in the html code the path is wrong!

Wrong in HTML, but working because reflect3.php finds the files
img src="./images/1317986502.png" ongdesc="" width="380" height="253" alt="" />

Correct in HTML, but reflect3.php cannot find the files
img src="./fileadmin/teamtemplate/images/1317986502.png" ongdesc="" width="380" height="253" alt="" />

Faulty code in imageflow.js

version = (my.reflectionPNG) ? '3' : '2';
src = my.imagePath+node.getAttribute('src',2);
src = my.reflectPath+'reflect'+version+'.php?img='+src+my.reflectionGET;
node.setAttribute('src',src);

my.reflectionGET should explode the string so that it takes only the last 1317986502.png.

Working Solution:

/* Add 'reflect.php?img=' */
if(my.reflections === true)
{
    version = (my.reflectionPNG) ? '3' : '2';
    if(my.imagePath === "") {
        src = my.imagePath+node.getAttribute('src',2);
        src = my.reflectPath+'reflect'+version+'.php?img='+src+my.reflectionGET;
    } else {
        var imagePath = node.getAttribute('src',2);
        var slash = "/";
        var lastOccurence = imagePath.lastIndexOf(slash);
        var withoutPath = imagePath.substring(lastOccurence, imagePath.length);
        src = my.imagePath+withoutPath;
        src = my.reflectPath+'reflect'+version+'.php?img='+src+my.reflectionGET;
    }
    node.setAttribute('src',src);
}
testing
  • 19,681
  • 50
  • 236
  • 417
  • Imageflow is a widely used library, so I doubt it has faulty code. I honestly can't make heads or tails of your question. `At the same time the code is also given as HTML but wrong because it should be...` ??? Just make your question consist of your folder structure, your imageflow instantiation code and your current output. The rest is confusing. – mrtsherman Oct 07 '11 at 15:22
  • Imageflow worked as standalone plugin, but the integration failed. I'd developed a solution (see my question), which seems to work for me. If you read the code you know what I mean. Also I've removed many things from my question. The reason why it was so confusing is that I analyzed the problem and developed a solution while writing the question. I gave examples and what the output would be. Also I'm wasting two hours for a path problem like this - so I was in hurry .. – testing Oct 07 '11 at 15:44
  • Ah, I see. Glad that you got it working. Funny, I wrote a Wordpress image-flow plugin myself last year for my wife's blog. Share it with the world! – mrtsherman Oct 07 '11 at 16:00
  • "Imageflow is a widely used library, so I doubt it has faulty code." I have never noticed that because a piece of software - even OS software - is widely used, that it is necessarily bug free. The bug that "tester" describes is real - I first noted it about 2 years go and worked around it by including the folder name in each item's IMG tag. Thanks for the patch, tester :) –  Dec 18 '11 at 17:44

0 Answers0