使用JSON从PHP中提取一个自动图像蒙太奇

Incorporating an Automatic Image Montage using JSON to pull from PHP

本文关键字:一个 蒙太奇 图像 JSON PHP 提取 使用      更新时间:2023-09-26

我发现了这个自动图像蒙太奇,我正试图在我的网站上使用,然而,图像已经硬编码到HTML中。我想动态地引入它们,这样我就可以很容易地从数据库中更改图像。

图像蒙太奇:http://tympanus.net/Development/AutomaticImageMontage/index8.html

我设法使用jQuery输入了我的图像,但图像高度和左侧的CSS计算是使用JavaScript添加的。现在我不再直接将图像硬编码为HTML,似乎这些计算根本没有发生。有人知道如何解决这个问题,以便在加载图像后动态计算图像吗。

我的网站:http://129.219.78.186/~masgis/pupychow/index8.html

为什么不使用PHP加载图像?

只需将其放入容器内示例中的静态图像所在位置即可:

<?php
$dir="/home/user/images";
$dir_handle = @opendir($dir) or die("Unable to open $path");
while ($file = readdir($dir_handle)) 
{
    if($file!="." && $file!="..") {
        echo "<a href='"#'"><img src='"images/$file'"></img></a>'n";
    }
}
closedir($dir_handle);
?>

这对我很有效。