Skip to content

Fix hero slider broken image when the estore-slider size isn't generated - #144

Open
iamprazol wants to merge 1 commit into
masterfrom
fix/hero-slider-missing-image-size-fallback
Open

iamprazol wants to merge 1 commit into
masterfrom
fix/hero-slider-missing-image-size-fallback

Conversation

@iamprazol

Copy link
Copy Markdown

Summary

  • Root-caused per estore-pro#14: wp_get_attachment_image_src( $image_id, 'estore-slider', false ) in inc/widgets/class-estore-woocommerce-product-slider.php returns false instead of an array when the theme's custom estore-slider image 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.
  • The old code unconditionally indexed the result with $image_url[0], which on false triggers Warning: Trying to access array offset on false; with display_errors on, that warning text gets echoed directly into the <img src="..."> attribute instead of a real URL, breaking the hero slider image entirely.
  • Falls back to the full-size image URL via wp_get_attachment_image_url( $image_id, 'full' ) whenever the estore-slider size lookup fails, matching the fix proposed in the issue.

Test plan

  • Directly exercised both the old and new code paths in a live WP shell (wp eval) with the exact false value wp_get_attachment_image_src() returns for this scenario: the old code emits Warning: Trying to access array offset on false and renders an empty src; the new code renders a valid, loadable full-size image URL with no warning.
  • php -l clean on the modified file.

Notes

  • estore-pro's own copy of this widget was already rewritten with a different (safe) implementation that doesn't hit this bug, so no change is needed there — this fix targets the Free estore theme, which is where the issue's own repro steps (Free-only demo) and linked file/line point.

Closes themegrill/estore-pro#14

…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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants