這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

Picture Element Thumbnails

描述

This plugin introduces a couple of nifty functions to replace the_post_thumbnail() & get_the_post_thumbnail() in exchange for the responsive picture element. Use:

get_the_post_picture(
    $fallback_image_size,
    array(
        $breakpoint_1=>$image_size_1,
        $breakpoint_2=>$image_size_2
    )
    [, $id, $atts]
);

For example:

<?php echo get_the_post_picture(
    'single-featured-sm',
    array(
        '(min-width:768px)'=>'single-featured-md',
        '(min-width:992px)'=>'single-featured-lg',
        '(min-width:1200px)'=>'single-featured'
    )
); ?>

While this says 4.0 for minimum version, I would wager it’ll be fine on most older installations.

安裝

  1. Install via the WordPress Plugin directory or upload this to your plugins folder.

  2. Activate from the Plugins screen on your Dashboard.

常見問題

What?

Adds the functions the_post_picture() and get_the_post_picture(). See the description for an example.

Why?

This is really a bigger question than the scope of this plugin, but see here.

Oh, you weren’t talking about the picture element as a whole. There exists at least one plugin that will out-of-the-box replace all <img> tags with “picture” elements and set breakpoints based on the image sizes. But if you need art direction, you need the HTML5 <picture> element. This plugin gives you control over A. Which elements are replaced and B. What your breakpoints are.

Does the order of my sizes array matter?

Yup. Pass them smallest image to largest.

Browser Support?

The plugin includes PictureFill.js. This should polyfill most browsers. If you have an issue, please report it!

Can I use my custom image sizes?

Yessir.

Can I contribute?

PRs are welcome! See GitHub.

評價

There are no reviews for this plugin.

貢獻者及開發者

“Picture Element Thumbnails” 是一個開源的軟體。以下的人對這個外掛作出了貢獻。

貢獻者

將 Picture Element Thumbnails 外掛本地化為台灣繁體中文版。

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

修改日誌

1.0

  • Initial launch!

1.0.2

  • Added get_the_attachment_picture() as an alternative to wp_get_attachment_image()

1.0.3

  • Resolve some notices regarding static functions

1.0.4

  • Resolve another static notice