
內容簡介
這個外掛可以在文章的特色圖片上添加自定義標題。它可以與Gutenberg和經典編輯器一起使用。
下面是它的工作方式:
如果沒有指定標題,該外掛將顯示媒體庫中定義的通用標題。
如果指定了標題,該外掛將顯示該標題,而不是媒體庫中定義的通用標題。
如果沒有指定標題並且媒體庫中也沒有標題,則不會顯示任何標題。
此外,該外掛還可以:
隱藏媒體庫中原始標題或自定義標題。
完全隱藏公共視圖中的特色圖片,而不必將其與文章分離。
配置多個選項以修改標題中使用的樣式。
使用自定義函數在主題的任何位置輸出標題文本。
使用簡碼在內容中輸出帶有標題的特色圖片。
為了保持語義代碼,該外掛將標題寫入 <figcaption> 標籤中。
版本1.21新增功能:與Divi佈景主題的兼容性。這是一個實驗性功能,允許該外掛與Divi佈景主題一起使用,因為有很多用戶需要。請注意,它可能無法適用於所有佈局,由於它替換了divi用於顯示特色圖片的功能,因此啟用時可能會對舊版本的Divi或如果核心佈景主題更新的情況造成問題。同樣地,可能需要在主題中添加自定義CSS來顯示您想要的標題。
格式
標題將採用 <figcaption> 元素和 wp-caption-text CSS類設置的格式,這在WordPress主題中很常見。
使用方法
該外掛可以開箱即用。要開始使用它,您只需要啟用它並在編輯頁面中使用新選項。對於高級用戶,您可以找到一個特殊的設置頁面,以微調一些細節。
轉到“設置>FSM自定義特色圖片標題”設置CSS和HTML參數:
標題文本的CSS:選擇其中一個選項,以修改標題容器中將使用的類/樣式(默認為wp-caption-text)。請注意,您可以指定多個用空格分隔的類別。
允許HTML代碼:選中此選項,如果您需要讓瀏覽器解析HTML標籤而不是顯示它們,則可以將標題文本解析為HTML。請記住,錯誤的HTML代碼或孤立的標籤可能會破壞您的佈局。
允許簡碼:選擇此選項以解析標題文本中存在的簡碼。請注意,如果簡碼返回HTML,它將不會被過濾,而不考慮“允許HTML代碼”選項的狀態;此外,複雜的簡碼輸出可能會改變您的佈局。啟用後,您可以像往常一樣在標題框中編寫要使用的簡碼,例如:Venetian landscape [myshortcode option1="text"]
在列表中顯示圖片標題:默認情況下禁用此功能。如果您希望在列表中顯示標題,例如在分類頁面,最新文章小工具等中顯示,則選擇此項目。請注意,一些主題可能會在圖片周圍添加容器(例如連結標籤),這可能會影響標題的外觀。
啟用與Divi佈景主題的兼容性:默認情況下禁用此功能。允許該外掛與Divi一起使用。有關此選項的更多信息,請閱讀說明和常問問題(Q&A)部分
簡碼
我們添加了一個簡碼,允許您在頁面中放置特色圖片(和標題)。只需在文章的內容編輯框中的任何位置編寫[FSM_featured_image]即可。
外掛標籤
開發者團隊
② 後台搜尋「FSM Custom Featured Image Caption」→ 直接安裝(推薦)
原文外掛簡介
This plugin allows adding custom captions to the featured images of the posts. It works with both Gutenberg and the classic editor.
That’s how it works:
If no caption is indicated, the plugin will display the generic caption defined in the Media Library.
If a caption is indicated, the plugin will display this caption instead of the generic caption defined in the Media Library.
If no caption is indicated and no legend exists in the Media Library, none will be displayed (obviously).
The plugin also allows to:
Hide the caption, either the original from the Media Library or the custom one.
Entirely hide the featured image in the public view, without having to de-attach it from the post.
Configure several options to modify the styles used in the caption.
Output the text of the caption anywhere in your theme using a custom function.
Output the featured image with caption inside your content with a shortcode.
For maintaining a semantic code, this plugin writes the caption in a
New in version 1.21: Compatibility with Divi themes. This is an experimental feature to allow the plugin to work with Divi, as many users requested. Note that it may not work for all layouts, and that since it replaces the function divi uses to show featured images, when enabled it may potentially cause problems with older versions of Divi or if the core theme is updated. As always, it may also be necessary to add custom css to your theme to show the captions the way you want
Format
The caption will adopt the format specified for the
Usage
The plugin works out of the box. To start using it, all you need to do is activate it and play with the new options in your edit page. For advanced users, you will found a special settings page for fine-tuning some details.
Go to Settings > FSM Custom Featured Image Caption to set up the CSS and HTML parameters:
CSS for caption text: Choose one of the options to modify the class/styles that will be used in the caption container (by default is wp-caption-text). Note that you can indicate more than one class separated with spaces.
Allow HTML code: Check it if you want to parse the caption text as HTML if you need the browser to parse HTML tags instead of showing them. Keep in mind that incorrect HTML code or orphan tags can break your layout.
Allow shortcodes: Check it if you want to parse the shortcodes present in the caption text. Note that if the shortcode returns HTML it will not be filtered, regardless of the “allow html code” option state; also, complex shortcodes output may alter your layout. When activated, you can write the shortcode you want to use in the caption box in the usual way, i.e. : Venetian landscape [myshortcode option1="text"]
Show image captions in lists: Disabled by default. Check if you want to show the caption when the featured image appears in lists, i.e. in a category page, in a widget with latest posts, etc. Note that some themes may add containers around the image (i.e. a link tag) witch can conflict with the aspect of the caption.
Enable compatibility with Divi themes: Disabled by default. Allows the plugin to work with Divi. Please read the description and the FAQ sections for more info about this option
Shortcode
We’ve added a shortcode that allows you to put the featured image (and it’s caption) in your page. Just write [FSM_featured_image] anywhere in the content edit box of your post or page to display it. You can also select the size of the image with the parameter “size”. Note that defined image sizes may differ between WordPress themes. The defaults are these: thumbnail, medium, medium_large, large and full.
By using the shortcode, the plugin will try to remove the featured image from your theme’s default position to prevent it from appearing twice. Anyway, this is as this is an experimental feature and results may fluctuate. It also will not appear in lists.
Note that the usage of the shortcode is not related to the “Allow shortcodes” option in the settings page.
Usage example: [FSM_featured_image size=thumb]
For developers
The plugin comes with two public functions that allow you to get or output the featured image caption of the current post anywhere in your template.
Once the plugin is activated, use to return a string containing the text that you can assign to a variable or where you like the caption be displayed.
Both functions accept parameters passed inside an array with the following keys:
tag: The tag (without brackets) you want to use as a container. By default is div. If set to false, it will remove it and will return the caption text.
class: The name of the class/classes you want to use for the container. Use spaces to separate them. Empty by default.
style: The CSS styles to be used in the container tag. Empty by default.
force_visibility: When set to true, it ignores the hide caption option defined by the post editor. Useful for displaying your caption in a different place, but showing the featured image. Default: false.
allow_html: like in the settings page, if set to true, allows the browser to parse the HTML code inside the caption text, else shows it as plain text. Default: false.
allow_shortcodes: again the same behaviour than in the settings page. Default: false.
ignore_original_caption: stops using captions defined in the media library as a substitution when the caption field is empty. Default: false.
Usage example: `php
the_FSM_featured_image_caption( array(‘tag’ => ‘p’, ‘class’ => ‘class1 class2’, ‘style’ => ‘color: red;’, ‘allow_html’=> true, ‘allow_shortcodes’=>true );
In Gutenberg themes, the plugin generates a nested
Translations
The plugin comes up with three complete translations:
English (en)
Spanish (es_ES)
Catalan (ca)
You can contribute to translating it into more languages at https://translate.wordpress.org/projects/wp-plugins/fsm-custom-featured-image-caption/
Coming soon
More options for selecting the text to be used as the caption, allowing to choose amongst image Title / Caption / Alt Text / Description and custom text.
Options to fine-tune the shortcode.
Have more ideas? We are open to hearing!







