簡體   English   中英

如何使Pinterest按鈕獲取真實尺寸的博客圖像而不是縮略圖

[英]How to make Pinterest button grab a real size blogger image instead a thumbnail

我在博客上使用了Pinterest按鈕

<li><a class='pinterest share-tooltip share-tooltip-top' data-share-tooltip='Share on Pinterest' expr:href='&quot;http://pinterest.com/pin/create/button/?url=&quot; + data:post.url + &quot;&amp;media=&quot; + data:post.firstImageUrl + &quot;&amp;description=&quot; + data:post.title' target='_blank'><i class='fa fa-pinterest'/>Pinterest</a></li>

如您所見,我正在使用data:post.firstImageUrl作為圖像的來源...但是問題是我使我的拳頭圖像僅以縮略圖(中等大小)無法完整顯示。當我使用此數據時:post.firstImageUrl ...僅共享縮略圖而不是真正的圖像

這是我從data:post.firstImageUrl獲得的縮略圖URL的示例

https://3.bp.blogspot.com/-W-g2qYS-Kh0/V5gs0FvhpKI/AAAAAAAAFSY/yh_3p00aSA4-fRa65NH4cQ83iEngZhDeACLcB/s640/BMW-M5-30-Jahre-2014-1.jpg

這是我想要的全尺寸圖片網址

https://3.bp.blogspot.com/-W-g2qYS-Kh0/V5gs0FvhpKI/AAAAAAAAFSY/yh_3p00aSA4-fRa65NH4cQ83iEngZhDeACLcB/s1600/BMW-M5-30-Jahre-2014-1.jpg

如您所見,不同之處僅在於xxx:// xxx / xxx / s640 / xxx和xxx:// xxx / xxx / s1600 / xxx ...

我的問題是如何將URL部分s640更改為s1600,以及如何將其分配給我的pinterest按鈕?

我曾見過有人使用JavaScript更改此URL部分/ s640 /,他用它來自動調整縮略圖大小,我不熟悉JavaScript,所以我不太了解,這是代碼

img src="'+image_url.replace('/s72-c/','/s'+image_size+'-c/')+'" alt="'+post_title+'"/

您可以使用此Pastie中的腳本。 但這需要一些改變。

<script type='text/javascript'>
//<![CDATA[
function thumbnail_resize(image_url) {
  var image_size = 1600;
  image_tag = image_url.replace('/s640/','/s' + image_size + '/');
  if(image_url != "") {
    return image_tag;
  } else {
    return "";
  }
}
//]]>
</script>

在這里,我們替換了圖像的URL。

<script type='text/javascript'>document.write('&lt;a class=&quot;pinterest share-tooltip share-tooltip-top&quot; data-share-tooltip=&quot;Share on Pinterest&quot; href=&quot;http://pinterest.com/pin/create/button/?url=<data:post.url/>&amp;media=' + thumbnail_resize(&quot;<data:post.firstImageUrl/>&quot;) + '&amp;description=<data:post.title/>&quot;&gt;PING&lt;/a&gt;');</script>

在這里,我們通過JavaScript粘貼了鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM