Skip to content
This repository was archived by the owner on Apr 2, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions inc/class-img-shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ public static function get_shortcode_ui_args() {
'type' => 'text',
'placeholder' => esc_attr__( 'URL to link to (if above link is "custom")', 'image-shortcake' ),
),

array(
'label' => esc_html__( 'Force display captionified HTML?', 'image-shortcake' ),
'attr' => 'forcecaptionify',
'type' => 'checkbox',
),
),
);

Expand Down Expand Up @@ -155,19 +161,18 @@ public static function reversal( $content ) {
public static function callback( $attr ) {

$attr = wp_parse_args( $attr, array(
'attachment' => 0,
'size' => 'full',
'alt' => '',
'classes' => '',
'caption' => '',
'align' => 'alignnone',
'linkto' => '',
'attachment' => 0,
'size' => 'full',
'alt' => '',
'classes' => '',
'caption' => '',
'align' => 'alignnone',
'linkto' => '',
'forcecaptionify' => true,
) );

/**
*
*
* @param
* Filter default attributes
*/
$attr = apply_filters( 'img_shortcode_attrs', $attr );

Expand Down Expand Up @@ -224,8 +229,9 @@ public static function callback( $attr ) {
*/
$image_html = apply_filters( 'img_shortcode_output_after_linkify', $image_html, $attr );

// If a caption is specified, wrap the image in the appropriat caption markup.
if ( ! empty( $attr['caption'] ) ) {
// If a caption is specified, or if `forcecaptionify` is true, wrap the
// image in the appropriate caption markup.
if ( ! empty( $attr['caption'] ) || $attr['forcecaptionify'] ) {

// The WP caption element requires a width defined
if ( empty( $attr['width'] ) ) {
Expand Down