0
如何從/me/home
獲取照片的寬度和高度?graph.facebook.com/me/home照片寬度和高度
我嘗試
/me/home?fields=picture,width,height
但沒有結果的寬度和高度。
如何從/me/home
獲取照片的寬度和高度?graph.facebook.com/me/home照片寬度和高度
我嘗試
/me/home?fields=picture,width,height
但沒有結果的寬度和高度。
圖形API不會根據寬度和高度返回圖像的大小。 但是,您可以指定大小,你想用「高度」和檢索「寬度」參數,如:
me/picture?width=70&height=90
此外,還有一些默認的大小,你可以檢索使用「類型」參數: https://developers.facebook.com/docs/reference/api/using-pictures/#sizes
最後,您可以檢索任意大小的圖片並以編程方式獲取其寬度和高度。
javascript例子:
現代瀏覽器和IE9 +:
var width = document.getElementById('yourImg').naturalWidth,
height = document.getElementById('yourImg').naturalHeight;
console.log(width, height);
對於IE8-:
var img = new Image(), // or document.createElement('img')
width,
height;
img.onload = function() {
width = this.width;
height = this.height;
};
img.src = 'http://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/626_someid_202729_q.jpg'
console.log(width, height);
的事情是瞭解寬度和高度_before_頁面早餐。我需要爲
標籤定義寬度和高度屬性以避免頁面痙攣。 –
在請求之前和之後設置
的寬度和高度屬性有什麼區別? –
設置高度屬性時,整個頁面在加載圖像前後具有相同的固定高度。否則
元素具有零高度和寬度,直到瀏覽器知道尺寸。這會導致互聯網連接速度變慢。 –