Skip to content

Improve hero imagery accessibility and CTA fallbacks#35

Open
GalToast wants to merge 1 commit into
mainfrom
codex/verify-legitimacy-of-reported-bugs
Open

Improve hero imagery accessibility and CTA fallbacks#35
GalToast wants to merge 1 commit into
mainfrom
codex/verify-legitimacy-of-reported-bugs

Conversation

@GalToast
Copy link
Copy Markdown
Owner

@GalToast GalToast commented Oct 2, 2025

Summary

  • render hero artwork via the stored attachment ID so responsive sources, lazy-loading, and meaningful alt text are exposed instead of always hiding the image
  • keep CTA and service card fallback text visible to assistive tech while styling .is-static states as neutral copy instead of faux links
  • ignore trashed "Home" pages during activation seeding and document the WordPress 5.9 minimum alongside the latest fixes

Testing

  • npm run build

https://chatgpt.com/codex/tasks/task_e_68ddfef9251083248e681d493cf6675a

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @GalToast, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the theme's accessibility and reliability. It improves how hero images are rendered to ensure proper alt text, responsive image sources, and lazy-loading are utilized. Additionally, it refines the presentation of static call-to-action elements, making them accessible to assistive technologies while visually distinguishing them from active links. The update also includes a fix for the home page seeding process, preventing issues when a "Home" page is in the trash, and aligns the documented WordPress compatibility with the theme's actual requirements.

Highlights

  • Hero Image Accessibility: Hero imagery now leverages WordPress attachment IDs for responsive images, lazy-loading, and proper alt text, dynamically setting aria-hidden based on alt text presence.
  • CTA Fallback Readability: Call-to-action (CTA) and service card fallback texts are now visible to assistive technologies and styled neutrally, preventing them from appearing as clickable links when no URL is set.
  • Home Page Seeding Logic: The activation routine for seeding the "Home" page now correctly ignores trashed pages, ensuring the landing pattern is applied to a live page or a newly created one.
  • WordPress Minimum Version Update: The documented minimum WordPress version has been updated to 5.9 across all relevant files to reflect the theme's actual dependencies.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several valuable accessibility improvements and bug fixes. The changes to render hero images using attachment IDs for better accessibility, make static CTAs visible to assistive technologies, and handle trashed pages during home page seeding are all well-implemented. The documentation updates are also thorough and align with the code changes. I've found one area in the hero block's render file where the code could be refactored to reduce duplication, for which I've provided a suggestion.

Comment thread blocks/hero/render.php
Comment on lines +151 to +199
$hero_image_markup = '';

if ( 0 !== $hero_image_id ) {
$image_attributes = array(
'class' => 'hero__decorative-image',
'loading' => 'lazy',
'alt' => $hero_image_alt,
);

if ( '' === $hero_image_alt ) {
$image_attributes['role'] = 'presentation';
}

$hero_image_markup = wp_get_attachment_image( $hero_image_id, 'full', false, $image_attributes );

if ( ! $hero_image_markup && '' !== $hero_image_url ) {
$fallback_attributes = $image_attributes;
$fallback_attributes['src'] = $hero_image_url;

$hero_image_markup = '<img';

foreach ( $fallback_attributes as $attr_name => $attr_value ) {
$escaped_value = 'src' === $attr_name ? esc_url( $attr_value ) : esc_attr( $attr_value );
$hero_image_markup .= sprintf( ' %s="%s"', esc_attr( $attr_name ), $escaped_value );
}

$hero_image_markup .= ' />';
}
} elseif ( '' !== $hero_image_url ) {
$attr_pairs = array(
'src' => $hero_image_url,
'class' => 'hero__decorative-image',
'loading' => 'lazy',
'alt' => $hero_image_alt,
);

if ( '' === $hero_image_alt ) {
$attr_pairs['role'] = 'presentation';
}

$hero_image_markup = '<img';

foreach ( $attr_pairs as $attr_name => $attr_value ) {
$escaped_value = 'src' === $attr_name ? esc_url( $attr_value ) : esc_attr( $attr_value );
$hero_image_markup .= sprintf( ' %s="%s"', esc_attr( $attr_name ), $escaped_value );
}

$hero_image_markup .= ' />';
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The logic for manually building the <img> tag is duplicated in two places: once as a fallback for wp_get_attachment_image(), and again for when only a URL is provided. This can be refactored to a single block to improve maintainability and reduce code duplication.

$hero_image_markup = '';
$manual_img_attrs  = null;

if ( 0 !== $hero_image_id ) {
    $image_attributes = array(
        'class'   => 'hero__decorative-image',
        'loading' => 'lazy',
        'alt'     => $hero_image_alt,
    );

    if ( '' === $hero_image_alt ) {
        $image_attributes['role'] = 'presentation';
    }

    $hero_image_markup = wp_get_attachment_image( $hero_image_id, 'full', false, $image_attributes );

    if ( ! $hero_image_markup && '' !== $hero_image_url ) {
        $manual_img_attrs = $image_attributes;
        $manual_img_attrs['src'] = $hero_image_url;
    }
} elseif ( '' !== $hero_image_url ) {
    $manual_img_attrs = array(
        'src'     => $hero_image_url,
        'class'   => 'hero__decorative-image',
        'loading' => 'lazy',
        'alt'     => $hero_image_alt,
    );

    if ( '' === $hero_image_alt ) {
        $manual_img_attrs['role'] = 'presentation';
    }
}

if ( is_array( $manual_img_attrs ) ) {
    $hero_image_markup = '<img';

    foreach ( $manual_img_attrs as $attr_name => $attr_value ) {
        $escaped_value     = 'src' === $attr_name ? esc_url( $attr_value ) : esc_attr( $attr_value );
        $hero_image_markup .= sprintf( ' %s="%s"', esc_attr( $attr_name ), $escaped_value );
    }

    $hero_image_markup .= ' />';
}

@GalToast
Copy link
Copy Markdown
Owner Author

GalToast commented Oct 2, 2025

jules could you handle the commit conflicts prioritizing most recent changes? This branch is old, from yesterday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant