Php Imageflow路径错误,因为它添加了来自HTML的路径

Php Imageflow路径错误,因为它添加了来自HTML的路径,php,javascript,path,imageflow,Php,Javascript,Path,Imageflow,我在一个Typo3站点中包含了一个PHP脚本。此PHP脚本生成img标记,该标记将自动作为脚本的基础 imageflow文件位于文件夹/fileadmin/teamtemplate中。/fileadmin/teamtemplate/images中的图像 在imageflow.js中,我有以下参数: this.defaults = { imagePath: '', /* Path to the imag

我在一个Typo3站点中包含了一个PHP脚本。此PHP脚本生成img标记,该标记将自动作为脚本的基础

imageflow文件位于文件夹/fileadmin/teamtemplate中。/fileadmin/teamtemplate/images中的图像

在imageflow.js中,我有以下参数:

this.defaults =
{
    imagePath:          '',                                    /* Path to the images relative to the reflect_.php script */
    reflectPath:        'fileadmin/teamtemplate/',             /* Path to the reflect_.php script */
在html文件的输出中,我有以下内容:

  img  src="./images/1317986502.png" ongdesc="" width="380" height="253" alt="" />
(很抱歉,我没有找到如何发布HTML代码。)Imageflow创建以下路径,该路径正在运行:

fileadmin/teamtemplate/reflect3.php?img=./images/1317986502.png
问题如下:

/* 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);
}
对于reflect3.php,路径是正确的,因为(./images)是可访问的:

-reflect3.php
-图像/
--1317986502.png

Imageflow通常采用html img src标记中给出的URL。php现在可以访问图像,但是在html代码中路径是错误的

在HTML中出错,但正在工作,因为reflect3.php找到文件
img src=“./images/1317986502.png”ongdesc=”“width=“380”height=“253”alt=”“/>

在HTML中正确,但reflect3.php找不到文件
img src=“./fileadmin/teamtemplate/images/1317986502.png”ongdesc=”“width=“380”height=“253”alt=”“/>

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应该分解字符串,以便只使用最后的1317986502.png

工作解决方案:

/* 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);
}

Imageflow是一个广泛使用的库,所以我怀疑它是否有错误的代码。老实说,我不能理解你的问题<代码>同时,代码也以HTML形式给出,但错误,因为它应该是…???只需让您的问题由文件夹结构、imageflow实例化代码和当前输出组成。其余部分令人困惑。Imageflow作为独立插件工作,但集成失败。我已经制定了一个解决方案(见我的问题),这似乎对我有效。如果你读了密码,你就知道我的意思了。我还从我的问题中删除了很多东西。之所以如此混乱,是因为我在写问题的时候分析了问题并提出了解决方案。我给出了一些例子以及输出结果。我也在为这样的路径问题浪费两个小时-所以我很匆忙..啊,我明白了。很高兴你让它工作了。有趣的是,去年我自己为我妻子的博客写了一个Wordpress图像流插件。与全世界分享!“Imageflow是一个广泛使用的库,所以我怀疑它是否有错误的代码。”我从来没有注意到,因为一个软件——甚至是操作系统软件——被广泛使用,它必然是无缺陷的。“tester”描述的bug是真实的——我在大约两年前第一次注意到它,并通过在每个项目的IMG标记中包含文件夹名称来解决它。谢谢你的补丁,测试人员:)