Conversation
…edia library attachment_url_to_postid() returns 0 for a slide image that isn't in the media library, so wp_get_attachment_image_src() returns false and the width/height were read from it unguarded. They are now only printed when the image data exists; the image itself still renders from its URL. Verified live: a slide with an external image URL logged two "Trying to access array offset on false" warnings before and none after, and the image still renders.
QA suite — refused, no regression specThis PR changes product source but adds no spec, so the suite was Source files changed with no matching spec |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review issues remain.
Review effort: Lite
Findings: None
What changed in this PR
Fixes slider warnings for images not associated with media-library attachments while preserving image rendering.
Changes:
- Guards optional width and height attributes.
- Preserves external or missing-library image URLs.
| File | Description |
|---|---|
inc/header-functions.php |
Safely renders slider image dimensions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Free-theme counterpart of themegrill/accelerate-pro#48 (also tracked as the closed #79).
Changes proposed in this Pull Request:
The slider threw "Trying to access array offset on value of type bool" for any slide whose image isn't in the media library (an external URL, or one that was removed).
attachment_url_to_postid()returns 0 for those, sowp_get_attachment_image_src()returnsfalse, andheader-functions.phpthen read[1]and[2]from it for the<img>width and height without checking. The width and height are now only printed when the image data exists; the image still renders from its URL either way.Verified live on the front page with a slide pointing at an external image URL (forced temporarily, since removed): before, two warnings (width and height); after, none, and the
<img>still renders with itssrcandalt.How to test the changes in this Pull Request:
WP_DEBUGandWP_DEBUG_DISPLAY.https://example.com/a.jpg).<img>still gets width and height.Types of changes:
Other information:
Changelog entry
Fix - PHP warning in the slider when a slide image is not in the media library.