简体   繁体   English

来自文件夹的函数 fetch_images() 不是 api

[英]function fetch_images() from folder not api

I have a responsive-image-gallery- code in HTML5 that fetches an image from Filker.我在 HTML5 中有一个响应式图像库代码,可以从 Filker 获取图像。 I want to fetch image from img folder and get the title automatically from the .jpg name this is the code我想从img文件夹中获取图像并从 .jpg 名称中自动获取标题这是代码

// fetch images from Flickr
function fetch_images() {

    $.getJSON(api_flickr, {
        tags: $("#searchinput").val(),
        tagmode: "any",
        format: "json"
    })
    .done(function(data) {
        $.each(data.items, function(i, item) {
            var url = item.media.m;
            var title = item.title;
            var elem = $("<div class='my show'><img src='"+url+"'/><div>"+
                         title+"</div>");
            images.append(elem);
        });
        // add more-div and resize
        images.append($("#morediv").clone().removeAttr("id"));
        resize_images();
    });

}

Flicker has an API that provides JavaScript with a JSON-formatted list of filenames. Flicker 有一个 API,它为 JavaScript 提供了一个 JSON 格式的文件名列表。

In order for your script to do the same, you need to either provide it with the same type of API (maybe with a PHP script) or with a list of the filenames in the img folder.为了让您的脚本执行相同的操作,您需要为其提供相同类型的 API(可能使用 PHP 脚本)或 img 文件夹中的文件名列表。

References:参考:

JSON - Learn what JSON is JSON - 了解什么是 JSON

PHP Script - Learn how to create a PHP script to output what you need PHP 脚本- 了解如何创建 PHP 脚本以输出您需要的内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM