Conversation
…n't generated wp_get_attachment_image_src() returns false instead of an array when the estore-slider intermediate size hasn't been generated for an attachment (a known side effect of some demo-import pipelines not regenerating every custom image size). Indexing that false value with [0] triggered a PHP warning that got echoed directly into the img src attribute, leaving the hero slider image broken. Ref: themegrill/estore-pro#14
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Fixes broken hero slider images when the custom estore-slider size is unavailable.
Changes:
- Safely handles failed image-size lookups.
- Falls back to the full-size attachment URL.
- Escapes and renders the resolved URL.
| File | Description |
|---|---|
inc/widgets/class-estore-woocommerce-product-slider.php |
Adds safe full-size image fallback handling. |
💡 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.
Summary
wp_get_attachment_image_src( $image_id, 'estore-slider', false )ininc/widgets/class-estore-woocommerce-product-slider.phpreturnsfalseinstead of an array when the theme's customestore-sliderimage size hasn't been generated for that attachment — a known side effect of some demo-import pipelines not regenerating every custom theme image size for imported media.$image_url[0], which onfalsetriggersWarning: Trying to access array offset on false; withdisplay_errorson, that warning text gets echoed directly into the<img src="...">attribute instead of a real URL, breaking the hero slider image entirely.wp_get_attachment_image_url( $image_id, 'full' )whenever theestore-slidersize lookup fails, matching the fix proposed in the issue.Test plan
wp eval) with the exactfalsevaluewp_get_attachment_image_src()returns for this scenario: the old code emitsWarning: Trying to access array offset on falseand renders an emptysrc; the new code renders a valid, loadable full-size image URL with no warning.php -lclean on the modified file.Notes
estoretheme, which is where the issue's own repro steps (Free-only demo) and linked file/line point.Closes themegrill/estore-pro#14