Skip to content

Commit

Permalink
Supplies alt text for sponsor images; adds meta attribute for sponsor…
Browse files Browse the repository at this point in the history
… logo to override value. (#673)

Signed-off-by: Chris Abraham <[email protected]>
  • Loading branch information
cjyabraham committed Mar 9, 2023
1 parent 980e3d6 commit 918d9f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,18 @@ public function create_sidebar( $sidebars ) {
'min' => 50,
'max' => 150,
),
array(
'type' => 'text',
'id' => 'alt_text',
'data_type' => 'meta',
'data_key' => 'alt_text',
'label' => __( 'Alt Text' ),
'register_meta' => true,
'ui_border_top' => true,
'default_value' => '',
'help' => __( 'Provide alt text for sponsor image; if not provided then the sponsor title will be used.' ),
'placeholder' => __( 'Google' ),
),
),
),
),
Expand Down
8 changes: 7 additions & 1 deletion web/wp-content/plugins/sponsors-dynamic-block/src/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,15 @@ function( $sponsor ) {
$id = get_the_ID();
$forwarding_url = esc_url( get_post_meta( $id, 'lfes_sponsor_url', true ) );
$size = get_post_meta( $id, 'lfes_sponsor_size', true );
$alt_text = esc_attr( get_post_meta( $id, 'lfes_sponsor_alt_text', true ) );

if ( ! $alt_text ) {
$alt_text = get_the_title();
}

$out .= '<div class="sponsors-logo-item">';
if ( $forwarding_url ) {
$out .= '<a href="' . $forwarding_url . '"';
$out .= '<a href="' . $forwarding_url . '" title="Go to ' . $alt_text . '"';
if ( is_numeric( $size ) && '100' !== $size ) {
$scale = $size / 100;
$out .= ' style="-webkit-transform: scale(' . $scale . '); -ms-transform: scale(' . $scale . '); transform: scale(' . $scale . ');"';
Expand All @@ -141,6 +146,7 @@ function( $sponsor ) {
array(
'class' => 'logo',
'loading' => 'lazy',
'alt' => $alt_text . ' logo',
)
);

Expand Down

2 comments on commit 918d9f9

@LFCIBot
Copy link
Collaborator

@LFCIBot LFCIBot commented on 918d9f9 Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visit Site

Created multidev environment pr-747 for lfasiallcci.

@LFCIBot
Copy link
Collaborator

@LFCIBot LFCIBot commented on 918d9f9 Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visit Site

Created multidev environment pr-747 for lfeventsci.

Please sign in to comment.