Changeset 3238162
- Timestamp:
- 02/10/2025 07:57:52 PM (14 months ago)
- Location:
- picture-tag
- Files:
-
- 7 edited
- 8 copied
-
tags/1.3.0 (copied) (copied from picture-tag/trunk)
-
tags/1.3.0/README.md (copied) (copied from picture-tag/trunk/README.md) (2 diffs)
-
tags/1.3.0/includes (copied) (copied from picture-tag/trunk/includes)
-
tags/1.3.0/includes/settings.php (copied) (copied from picture-tag/trunk/includes/settings.php)
-
tags/1.3.0/includes/shortcode.php (modified) (1 diff)
-
tags/1.3.0/includes/template-functions.php (modified) (1 diff)
-
tags/1.3.0/index.php (copied) (copied from picture-tag/trunk/index.php)
-
tags/1.3.0/picture-tag.php (copied) (copied from picture-tag/trunk/picture-tag.php) (2 diffs)
-
tags/1.3.0/readme.txt (copied) (copied from picture-tag/trunk/readme.txt) (2 diffs)
-
tags/1.3.0/screenshot-1.png (copied) (copied from picture-tag/trunk/screenshot-1.png)
-
trunk/README.md (modified) (2 diffs)
-
trunk/includes/shortcode.php (modified) (1 diff)
-
trunk/includes/template-functions.php (modified) (1 diff)
-
trunk/picture-tag.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
picture-tag/tags/1.3.0/README.md
r3212753 r3238162 1 1 # Picture Tag 2 2 3 **Version:** 1. 2.03 **Version:** 1.3.0 4 4 **Author:** Artilab 5 5 … … 91 91 8. fetchpriority (optional): 92 92 Specifies the priority for resource fetching. Common values: high, low. 93 9. data-* (optional): 94 Supports custom data attributes for the `<img>` tag, allowing developers to pass additional metadata. 93 95 94 96 **Examples:** -
picture-tag/tags/1.3.0/includes/shortcode.php
r3209252 r3238162 19 19 */ 20 20 function arti_picture_tag_shortcode_handler( $atts ) { 21 // Define default attributes22 $atts = shortcode_atts(array(23 'id' => 0, // Attachment ID24 'size_1x' => 'large', // Default size for 1x25 'size_2x' => 'full', // Default size for 2x26 'alt' => '', // Alt attribute27 'title' => '', // Title attribute28 'class' => '', // Additional classes29 'loading' => 'lazy', // Loading attribute30 'fetchpriority' => 'low',// Fetch priority (e.g., "high")31 ), $atts, 'arti_picture');21 // Define default attributes 22 $default_atts = array( 23 'id' => 0, // Attachment ID 24 'size_1x' => 'large', // Default size for 1x 25 'size_2x' => 'full', // Default size for 2x 26 'alt' => '', // Alt attribute 27 'title' => '', // Title attribute 28 'class' => '', // Additional classes 29 'loading' => 'lazy', // Loading attribute 30 'fetchpriority' => 'low', // Fetch priority (e.g., "high") 31 ); 32 32 33 // Validate and sanitize attributes 34 $image_id = intval( $atts['id'] ); 35 $sizes = array( 36 '1x' => sanitize_text_field( $atts['size_1x'] ), 37 '2x' => sanitize_text_field( $atts['size_2x'] ), 38 ); 33 // get custom attributes (data-*) 34 $custom_data_atts = array(); 35 foreach ( $atts as $key => $value ) { 36 if ( strpos( $key, 'data-' ) === 0 ) { 37 $custom_data_atts[ $key ] = esc_attr( $value ); 38 } 39 } 39 40 40 // Prepare additional attributes for the <img> tag 41 $img_attr = array_filter( array( 42 'alt' => sanitize_text_field( $atts['alt'] ), 43 'title' => sanitize_text_field( $atts['title'] ), 44 'class' => sanitize_text_field( $atts['class'] ), 45 'loading' => sanitize_text_field( $atts['loading'] ), 46 'fetchpriority' => sanitize_text_field( $atts['fetchpriority'] ), 47 ) ); 41 // Merge user attributes with defaults 42 $atts = shortcode_atts( $default_atts, $atts, 'arti_picture' ); 48 43 49 // Return early if no image ID is provided 50 if ( ! $image_id ) { 51 return '<!-- No image ID provided -->'; 52 } 44 // Merge custom user attributes 45 $atts = array_merge( $atts, $custom_data_atts ); 53 46 54 // Generate the <picture> tag using the provided sizes and attributes 55 return arti_get_image_by_id( $image_id, $sizes, $img_attr ); 47 48 // Validate and sanitize attributes 49 $image_id = intval( $atts['id'] ); 50 $sizes = array( 51 '1x' => sanitize_text_field( $atts['size_1x'] ), 52 '2x' => sanitize_text_field( $atts['size_2x'] ), 53 ); 54 55 // Extract known attributes and prepare additional attributes 56 $img_attr = array_filter( array( 57 'alt' => sanitize_text_field( $atts['alt'] ), 58 'title' => sanitize_text_field( $atts['title'] ), 59 'class' => sanitize_text_field( $atts['class'] ), 60 'loading' => sanitize_text_field( $atts['loading'] ), 61 'fetchpriority' => sanitize_text_field( $atts['fetchpriority'] ), 62 ) ); 63 64 // Extract custom attributes (data-*) 65 foreach ( $atts as $key => $value ) { 66 if ( strpos( $key, 'data-' ) === 0 ) { 67 $img_attr[ $key ] = esc_attr( $value ); 68 } 69 } 70 71 // Return early if no image ID is provided 72 if ( ! $image_id ) { 73 return '<!-- No image ID provided -->'; 74 } 75 76 // Generate the <picture> tag using the provided sizes and attributes 77 return arti_get_image_by_id( $image_id, $sizes, $img_attr ); 56 78 } -
picture-tag/tags/1.3.0/includes/template-functions.php
r3209252 r3238162 116 116 'picture' => array(), 117 117 ); 118 119 // Allow custom data-* attributes 120 foreach ( $attr as $key => $value ) { 121 if ( strpos( $key, 'data-' ) === 0 ) { 122 $allowed_tags['img'][$key] = true; 123 } 124 } 118 125 119 126 echo wp_kses( $html, $allowed_tags ); -
picture-tag/tags/1.3.0/picture-tag.php
r3212753 r3238162 3 3 * Plugin Name: Picture Tag 4 4 * Description: Picture Tag with Custom Path Settings 5 * Version: 1. 2.05 * Version: 1.3.0 6 6 * Author: Artilab 7 7 * Author URI: https://artilab.pro/ … … 18 18 define( 'ARTI_PICTURE_TAG_PLUGIN', __FILE__ ); 19 19 define( 'ARTI_PICTURE_TAG_PLUGIN_DIR', untrailingslashit( dirname( ARTI_PICTURE_TAG_PLUGIN ) ) ); 20 define( 'ARTI_PICTURE_TAG_PLUGIN_VERSION', '1. 2.0' );20 define( 'ARTI_PICTURE_TAG_PLUGIN_VERSION', '1.3.0' ); 21 21 22 22 -
picture-tag/tags/1.3.0/readme.txt
r3212753 r3238162 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.4 7 Stable tag: 1. 2.07 Stable tag: 1.3.0 8 8 License: GPL-2.0-or-later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 49 49 == Changelog == 50 50 51 = 1.3.0 = 52 * Added support for custom data-* attributes in ```[arti_picture]``` shortcode. 53 * Added support for custom data-* attributes in the ```arti_the_image``` function. 54 51 55 = 1.2.0 = 52 56 * Added translation support for multilingual use. -
picture-tag/trunk/README.md
r3212753 r3238162 1 1 # Picture Tag 2 2 3 **Version:** 1. 2.03 **Version:** 1.3.0 4 4 **Author:** Artilab 5 5 … … 91 91 8. fetchpriority (optional): 92 92 Specifies the priority for resource fetching. Common values: high, low. 93 9. data-* (optional): 94 Supports custom data attributes for the `<img>` tag, allowing developers to pass additional metadata. 93 95 94 96 **Examples:** -
picture-tag/trunk/includes/shortcode.php
r3209252 r3238162 19 19 */ 20 20 function arti_picture_tag_shortcode_handler( $atts ) { 21 // Define default attributes22 $atts = shortcode_atts(array(23 'id' => 0, // Attachment ID24 'size_1x' => 'large', // Default size for 1x25 'size_2x' => 'full', // Default size for 2x26 'alt' => '', // Alt attribute27 'title' => '', // Title attribute28 'class' => '', // Additional classes29 'loading' => 'lazy', // Loading attribute30 'fetchpriority' => 'low',// Fetch priority (e.g., "high")31 ), $atts, 'arti_picture');21 // Define default attributes 22 $default_atts = array( 23 'id' => 0, // Attachment ID 24 'size_1x' => 'large', // Default size for 1x 25 'size_2x' => 'full', // Default size for 2x 26 'alt' => '', // Alt attribute 27 'title' => '', // Title attribute 28 'class' => '', // Additional classes 29 'loading' => 'lazy', // Loading attribute 30 'fetchpriority' => 'low', // Fetch priority (e.g., "high") 31 ); 32 32 33 // Validate and sanitize attributes 34 $image_id = intval( $atts['id'] ); 35 $sizes = array( 36 '1x' => sanitize_text_field( $atts['size_1x'] ), 37 '2x' => sanitize_text_field( $atts['size_2x'] ), 38 ); 33 // get custom attributes (data-*) 34 $custom_data_atts = array(); 35 foreach ( $atts as $key => $value ) { 36 if ( strpos( $key, 'data-' ) === 0 ) { 37 $custom_data_atts[ $key ] = esc_attr( $value ); 38 } 39 } 39 40 40 // Prepare additional attributes for the <img> tag 41 $img_attr = array_filter( array( 42 'alt' => sanitize_text_field( $atts['alt'] ), 43 'title' => sanitize_text_field( $atts['title'] ), 44 'class' => sanitize_text_field( $atts['class'] ), 45 'loading' => sanitize_text_field( $atts['loading'] ), 46 'fetchpriority' => sanitize_text_field( $atts['fetchpriority'] ), 47 ) ); 41 // Merge user attributes with defaults 42 $atts = shortcode_atts( $default_atts, $atts, 'arti_picture' ); 48 43 49 // Return early if no image ID is provided 50 if ( ! $image_id ) { 51 return '<!-- No image ID provided -->'; 52 } 44 // Merge custom user attributes 45 $atts = array_merge( $atts, $custom_data_atts ); 53 46 54 // Generate the <picture> tag using the provided sizes and attributes 55 return arti_get_image_by_id( $image_id, $sizes, $img_attr ); 47 48 // Validate and sanitize attributes 49 $image_id = intval( $atts['id'] ); 50 $sizes = array( 51 '1x' => sanitize_text_field( $atts['size_1x'] ), 52 '2x' => sanitize_text_field( $atts['size_2x'] ), 53 ); 54 55 // Extract known attributes and prepare additional attributes 56 $img_attr = array_filter( array( 57 'alt' => sanitize_text_field( $atts['alt'] ), 58 'title' => sanitize_text_field( $atts['title'] ), 59 'class' => sanitize_text_field( $atts['class'] ), 60 'loading' => sanitize_text_field( $atts['loading'] ), 61 'fetchpriority' => sanitize_text_field( $atts['fetchpriority'] ), 62 ) ); 63 64 // Extract custom attributes (data-*) 65 foreach ( $atts as $key => $value ) { 66 if ( strpos( $key, 'data-' ) === 0 ) { 67 $img_attr[ $key ] = esc_attr( $value ); 68 } 69 } 70 71 // Return early if no image ID is provided 72 if ( ! $image_id ) { 73 return '<!-- No image ID provided -->'; 74 } 75 76 // Generate the <picture> tag using the provided sizes and attributes 77 return arti_get_image_by_id( $image_id, $sizes, $img_attr ); 56 78 } -
picture-tag/trunk/includes/template-functions.php
r3209252 r3238162 116 116 'picture' => array(), 117 117 ); 118 119 // Allow custom data-* attributes 120 foreach ( $attr as $key => $value ) { 121 if ( strpos( $key, 'data-' ) === 0 ) { 122 $allowed_tags['img'][$key] = true; 123 } 124 } 118 125 119 126 echo wp_kses( $html, $allowed_tags ); -
picture-tag/trunk/picture-tag.php
r3212753 r3238162 3 3 * Plugin Name: Picture Tag 4 4 * Description: Picture Tag with Custom Path Settings 5 * Version: 1. 2.05 * Version: 1.3.0 6 6 * Author: Artilab 7 7 * Author URI: https://artilab.pro/ … … 18 18 define( 'ARTI_PICTURE_TAG_PLUGIN', __FILE__ ); 19 19 define( 'ARTI_PICTURE_TAG_PLUGIN_DIR', untrailingslashit( dirname( ARTI_PICTURE_TAG_PLUGIN ) ) ); 20 define( 'ARTI_PICTURE_TAG_PLUGIN_VERSION', '1. 2.0' );20 define( 'ARTI_PICTURE_TAG_PLUGIN_VERSION', '1.3.0' ); 21 21 22 22 -
picture-tag/trunk/readme.txt
r3212753 r3238162 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.4 7 Stable tag: 1. 2.07 Stable tag: 1.3.0 8 8 License: GPL-2.0-or-later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 49 49 == Changelog == 50 50 51 = 1.3.0 = 52 * Added support for custom data-* attributes in ```[arti_picture]``` shortcode. 53 * Added support for custom data-* attributes in the ```arti_the_image``` function. 54 51 55 = 1.2.0 = 52 56 * Added translation support for multilingual use.
Note: See TracChangeset
for help on using the changeset viewer.