dqsvf28682 2011-10-07 15:02
浏览 42

Imageflow路径错误,因为它添加了HTML中的路径

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);
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大