Repository navigation
Slider slide with no image renders broken <img> + leaks PHP warning, breaks mobile header #63
Description
Summary
A homepage slider slide that has text (title/description) but no image renders a broken <img> tag with a raw PHP warning leaked into its width/height HTML attributes. On mobile, when this is the visible slide, the slider container collapses in height and its caption overlaps the mobile menu toggle button.
Steps to Reproduce
- Customizer → Slider → configure a slide with a title and description but no image (e.g. Slide WooCommerce compatible. #4).
- Publish and load the homepage.
- Inspect the rendered
<img>for that slide. - Additionally, resize the viewport to a mobile width (375px) and reload while this slide is the first/active one shown.
Expected Result
A slide without an image should render gracefully — either omit the <img> tag or use a safe fallback — with no PHP errors reaching the HTML output, and the mobile header should remain usable regardless of which slide is active.
Actual Result
- The
<img>tag renders withsrc="", and itswidth/heightattributes contain a literal PHP warning:<img width="<br /><b>Warning</b>: Trying to access array offset on value of type bool in .../wp-content/themes/accelerate/inc/header-functions.php on line 94<br />" height="..." src="">
- On mobile (375px), with this image-less slide active,
#featured-slidercollapses to ~20px tall, and the slide's.entry-containercaption (absolutely positioned) renders on top of the.menu-togglebutton, producing an overlapping, illegible mobile header. Confirmed via bounding-rect inspection: caption top=269/bottom=316.5 vs. menu-toggle top=255/bottom=298.5.
Root Cause
inc/header-functions.php, function accelerate_featured_image_slider():
$attachment_post_id = attachment_url_to_postid( $accelerate_slider_image ); // 0 when no image
$image_value = wp_get_attachment_image_src( $attachment_post_id, 'full' ); // returns false
...
<img width="<?php echo esc_attr( $image_value[1] ); ?>" height="<?php echo esc_attr( $image_value[2] ); ?>" ... src="<?php echo esc_url( $accelerate_slider_image ); ?>">wp_get_attachment_image_src() returns false (not an array) when there's no valid attachment, so $image_value[1] / $image_value[2] trigger "Trying to access array offset on value of type bool" — which, with display_errors on, gets injected straight into the HTML attributes. The resulting zero-content image also has no defined height, which is what collapses the mobile slider container and lets the caption overlap the menu toggle.
Suggested Fix
Check that $image_value is a valid array (i.e. the slide actually has an image) before using it — and skip rendering the <img> (or figure) entirely when there is no image, rather than emitting a broken tag. Also worth giving #featured-slider/.slider-rotate a sane minimum height so a caption never overlaps site chrome above it.
Evidence
img.getAttribute('width')/getAttribute('height')returned the raw warning text, captured via live browser testing.- Mobile screenshot showing the "Menu" toggle visually overlapped by the slide caption with a broken-image icon.
Environment
- Accelerate 1.5.4, WordPress 7.1, PHP with
display_errorson (warning leak is masked but the underlying bug exists regardless of that setting) - Reproduced at desktop 1440×900 and mobile 375×812
Activity
iamprazol commentedon Sep 17, 2026
Corroborating this from a separate QA pass covering both Free demos (
accelerateandaccelerate-lifestyle-and-fashion) — the underlying warning atheader-functions.php:94is broader than just the "slide with no image" case described above.In my testing, every slide in both demos had a real, successfully-imported image (confirmed visually — the slider renders correctly, images display), yet the
Warning: Trying to access array offset on value of type bool in .../header-functions.php on line 94still fired repeatedly in the PHP error log on every single front-end page load (the header/slider renders sitewide, not just on the homepage). Confirmed viacurlthat withdisplay_errorson, the raw warning text is emitted directly into the page's HTML output on every request, not just for a deliberately image-less slide.This suggests the
attachment_url_to_postid()/wp_get_attachment_image_src()lookup described in the root-cause section above can also fail for slides that do have a valid, displaying image — likely because the slide's stored image URL doesn't resolve to a local attachment ID (e.g. still pointing at an externalthemegrilldemos.comURL, or a URL mismatch after import) even though the<img src>itself (driven by a separate variable) still renders correctly.Net effect: the suggested fix (null/array-check
$image_valuebefore use) is still exactly right, but it should be applied unconditionally for every slide render, not only reached for the documented "no image" repro case — otherwise the warning keeps firing on demos where every slide looks fully configured.iamprazol commentedon Sep 18, 2026
Consolidating issue tracking: this is tracked going forward in Accelerate Pro as themegrill/accelerate-pro#13 (labelled
free+prothere since it affects both themes). Closing this copy to avoid duplicate tracking.