內容簡介
使用 [website-screenshot] 短碼來自動插入最新的網站截圖。
短碼範例
// WordPress.org 的網站截圖
[website-screenshot url="https://wordpress.org" width="1680"]
// 您也可以調整所生成的圖像大小
[website-screenshot url="https://wordpress.org" width="1680" thumbnail_width="100"]
// 並且您可以設定自訂 HTML 標籤
[website-screenshot url="https://wordpress.org" target="_blank" class="my-image-class"]
參數
url (必填) – 網址
width – 截圖的寬度
height – 截圖的高度
thumbnail_width – 調整圖像至想要的寬度,保留原始比例
alt – 圖像替代文字
target – 設定連結開啟的瀏覽器目標。例如:使用 _blank 開啟新視窗
class – 為截圖加上樣式
在 PHP 中生成截圖
您也可以使用我們的 PHP 類別來生成截圖:
<img src="<?php echo WebsiteScreenshot::screenshot(['url' => 'https://wordpress.org']); ?>" />
注意事項
此外掛依賴於 screenshotapi.net,您應該在那裡建立帳戶,並將您的 API 令牌貼到設定頁面。
外掛標籤
開發者團隊
原文外掛簡介
Use the [website-screenshot] shortcode to automatically insert an up to date webiste screenshot.
Shortcode Examples
// Website screenshot of wordpress.org
[website-screenshot url="https://wordpress.org" width="1680"]
// You can also resize the generated images
[website-screenshot url="https://wordpress.org" width="1680" thumbnail_width="100"]
// And you can add custom html tags
[website-screenshot url="https://wordpress.org" target="_blank" class="my-image-class"]
Parameters
url (required) – The url
width – the width of the screenhsot
height – the height of the screenshot
thumbnail_width – Resize the image to the desired width, preserves the aspect ratio
alt – the image alt text
target – browser target. For example: use _blank to open in a new window
class – add a class to the screenshot
Generating the screenshot in PHP
You can also use our PHP class to generate a screenshot:
Notes
This plugin relies on screenshotapi.net you should create an account there and paste your API token into the settings page.
