-1
我想知道如何將FLICKR中的圖片嵌入到網站中,現在我只能獲取圖像的URL,但我想要用它獲取整個圖像。這裏是我的代碼:如何從Flickr中嵌入圖像,以便圖像顯示在網站上?
<!DOCTYPE html>
<html>
<head>
<script src="jquery-min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
API_KEY = 'YOURAPIKEY'; //INSERT API KEY
USER_ID = '[email protected]'; //ENTER USER ID
var photolist = [];
$.getJSON('https://www.flickr.com/services/rest/?method=flickr.people.getPhotos&api_key=' + API_KEY + '&user_id=' + USER_ID + '&format=json&jsoncallback=?', function(rest) {
var numPhotos = rest.photos.pages;
for (var u =1; u < numPhotos + 1; u++) {
$.getJSON('https://www.flickr.com/services/rest/?method=flickr.people.getPhotos&api_key=' + API_KEY + '&user_id=' + USER_ID + '&format=json&page=' + u + '&jsoncallback=?', function(results) { var targetDiv = $('#fotolist')
for (var m =0; m < results.photos.total; m++) {
targetDiv.append("https://www.flickr.com/" +
results.photos.photo[m].owner + "/" + results.photos.photo[m].id + "<br />");
photolist.push("https://www.flickr.com/" + results.photos.photo[m].owner + "/" + results.photos.photo[m].id);
}
});
}
});
});
</script>
</head>
<body>
<div id="fotolist">
</div>
</body>
</html>
鏈接數組你可以把DOM(HTML),該鏈接withing IMG屬性通過jQuery。 – poush
對於每個鏈接創建一個帶有src屬性的圖像標籤到該鏈接,然後通過jQuery將該標籤添加到DOM – poush
@ user2686338我如何獲取每個鏈接並將它們作爲新圖像的來源? – user3205630