Skip to content

Commit

Permalink
add somes params for caption
Browse files Browse the repository at this point in the history
  • Loading branch information
asadowski10 committed Sep 30, 2021
1 parent 5d13819 commit 961a1ee
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.1.4 - 24 Sept 2021
- Update `ari_responsive_image_caption` filter to add attachment id and attachment attributes params
- Fix depecrated_function with check WordPress version

## 3.1.3 - 1 Sept 2021
- Add support of display caption
- Add new filter `ari_responsive_image_caption` to modify caption
Expand Down
4 changes: 2 additions & 2 deletions advanced-responsive-images.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Advanced Responsive Images
Version: 3.1.3
Version: 3.1.4
Plugin URI: https://github.com/asadowski10/advanced-responsive-images
Description: WordPress plugin to implement custom HTML markup for responsive images
Author: Alexandre Sadowski
Expand All @@ -19,7 +19,7 @@
}

// Plugin constants
define( 'ARI_VERSION', '3.1.3' );
define( 'ARI_VERSION', '3.1.4' );
define( 'ARI_MIN_PHP_VERSION', '5.4' );
define( 'ARI_VIEWS_FOLDER_NAME', 'ari' );

Expand Down
7 changes: 4 additions & 3 deletions classes/modes/picture-lazyload.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function render_image( $html = '' ) {
$content_with_attributes = str_replace( '%%attributes%%', $attributes, $content_with_sources );

$caption = $this->get_caption();
$content_with_caption = str_replace( '%%caption%%', esc_html( $caption ), $content_with_attributes );
$content_with_caption = str_replace( '%%caption%%', $caption, $content_with_attributes );

// Add pixel on all
$image = str_replace( [ '%%srcset%%', '%%srcgif%%', '%%data-location%%' ], [
Expand Down Expand Up @@ -178,7 +178,7 @@ private function check_tpl( $location_array, $html ) {
if ( isset( $this->args['data-tpl'] ) && ! empty( $this->args['data-tpl'] ) ) {
$main_tpl_name = $this->args['data-tpl'];
$main_tpl = ARI_JSON_DIR . 'tpl/' . $this->args['data-tpl'] . '.tpl';
} elseif ( ( isset( $this->args['data-caption'] ) && '1' === $this->args['data-caption'] ) && ! empty( $this->get_caption() ) ) {
} elseif ( ( isset( $this->args['data-caption'] ) && ( '1' === $this->args['data-caption'] || true === $this->args['data-caption'] ) ) && ! empty( $this->get_caption() ) ) {
$main_tpl_name = 'default-picture-caption';
$main_tpl = ARI_JSON_DIR . 'tpl/default-picture-caption.tpl';
}
Expand Down Expand Up @@ -288,6 +288,7 @@ private function get_alt_text() {
*/
private function get_caption() {
$legend = !empty( $this->args['caption'] ) ? $this->args['caption'] : wp_get_attachment_caption( $this->attachment_id );
return apply_filters( 'ari_responsive_image_caption', $legend );

return apply_filters( 'ari_responsive_image_caption', $legend, $this->attachment_id, $this->args );
}
}
6 changes: 5 additions & 1 deletion functions/utils.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php
if ( ! function_exists( 'bea_get_attachment_image' ) ) {
function bea_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = false, $attr = [] ) {
_deprecated_function( __FUNCTION__, '3.1.0', 'wp_get_attachment_image()' );
global $wp_version;
if ( version_compare( $wp_version, '5.6', '>' ) ) {
_deprecated_function( __FUNCTION__, '3.1.0', 'wp_get_attachment_image()' );
}

if ( ! isset( $attr['data-location'] ) ) {
$attr['data-location'] = 'No location filled in';

Expand Down

0 comments on commit 961a1ee

Please sign in to comment.