From fe4e0961c82f996d63fa180e78c55d9f453691f2 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Mon, 23 Jan 2023 20:47:02 +0100 Subject: [PATCH] I would keep it simple for now --- includes/class-shortcodes.php | 49 ++++++++++------------------------- templates/settings.php | 15 +---------- 2 files changed, 15 insertions(+), 49 deletions(-) diff --git a/includes/class-shortcodes.php b/includes/class-shortcodes.php index 280c10a..f1dd53d 100644 --- a/includes/class-shortcodes.php +++ b/includes/class-shortcodes.php @@ -266,31 +266,6 @@ class Shortcodes { return \sprintf( '%1$s', \esc_url( \wp_get_shortlink( $post->ID ) ) ); } - /** - * Generates output for the ap_thumbnail shortcode - * - * @param array $atts shortcode attributes - * @param string $content shortcode content - * @param string $tag shortcode tag name - * - * @return string - */ - public static function thumbnail( $atts, $content, $tag ) { - $post_id = get_the_ID(); - - if ( ! $post_id ) { - return ''; - } - - $image = \get_the_post_thumbnail_url( $post_id, 'thumbnail' ); - - if ( ! $image ) { - return ''; - } - - return $image; - } - /** * Generates output for the ap_image shortcode * @@ -307,18 +282,22 @@ class Shortcodes { return ''; } - $atts = shortcode_atts( array( 'size' => 'full' ), $atts, $tag ); + $atts = shortcode_atts( + array( + 'type' => 'full', + ), + $atts, + $tag + ); - if ( is_array( $atts ) && array_key_exists( 'size', $atts ) ) { - $registered_sizes = wp_get_registered_image_subsizes(); + $size = 'full'; - if ( array_key_exists( $atts['size'], $registered_sizes ) ) { - $size = intval( $atts['size'] ); - } - } - - if ( ! $size ) { - $size = 'full'; + if ( in_array( + $atts['type'], + array( 'thumbnail', 'medium', 'large', 'full' ), + true + ) ) { + $size = $atts['type']; } $image = \get_the_post_thumbnail_url( $post_id, $size ); diff --git a/templates/settings.php b/templates/settings.php index 8163808..8761179 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -7,18 +7,6 @@ 'welcome' => '', ) ); - -$image_sizes = wp_get_registered_image_subsizes(); -$thumbnail_size = $image_sizes['thumbnail']['width'] . 'x' . $image_sizes['thumbnail']['height'] . ' px'; -$registered_sizes = ''; - -foreach ( $image_sizes as $name => $size ) { - $registered_sizes .= $name . ', '; -} - -$registered_sizes = trim( $registered_sizes, ', ' ); -$registered_sizes .= '.'; - ?>
@@ -81,8 +69,7 @@ $registered_sizes .= '.';
  • [ap_shortlink type=xxx] - Hum, to prettify the Shortlinks. Type can be either: raw (the raw url, no escaping), esc (the html escaped url), html (default, an a tag to the url).', 'activitypub' ), 'default' ); ?>
  • [ap_hashtags] -
  • [ap_hashcats] -
  • -
  • [ap_image size=xxx] -
  • -
  • [ap_thumbnail] -
  • +
  • [ap_image type=full] -
  • [ap_author] -
  • [ap_authorurl] -
  • [ap_date] -