Skip to content

PHP Warning: unguarded array access when wp_get_attachment_image_src() returns false in slider #79

Description

@iamprazol

Summary

The homepage slider triggers a PHP Warning ("Trying to access array offset on value of type bool") whenever wp_get_attachment_image_src() returns false for a slide's image — which it does whenever the configured attachment ID doesn't resolve to a valid image (e.g. a deleted attachment, or any non-attachment value).

Where

inc/header-functions.php:94:

<img width="<?php echo esc_attr( $image_value[1] ); ?>" height="<?php echo esc_attr( $image_value[2] ); ?>" ...

$image_value comes from wp_get_attachment_image_src() earlier in the same function, with no is_array()/!empty() guard before the array access.

Live confirmation

Caught live in debug.log while browsing the front end with WP_DEBUG_LOG enabled — the warning fired on a normal homepage load with the default demo slider content:

PHP Warning:  Trying to access array offset on value of type bool in .../accelerate/inc/header-functions.php on line 94

Suggested fix

Guard the array access the same way Spacious/Spacious Pro's equivalent slider code already does — inc/header-functions.php there wraps the identical pattern in if ( ! empty( $image_attributes ) ) { ... } before touching [1]/[2].

Environment

Accelerate 1.5.4, WordPress 7.1, PHP 8.5 (identical unguarded pattern also present in Accelerate Pro — filed separately)

Found during a dedicated PHP 8.5 / WP 6.8+ compatibility sweep (enabled WP_DEBUG_LOG, crawled front-end and admin pages across all four themes) — prompted by ColorMag's own compatibility pass this cycle (CMAG-557, colormag#255/colormag-pro#248).

Activity

  1. iamprazol commented on Sep 18, 2026

    @iamprazol
    ContributorAuthor

    Consolidating issue tracking: this is tracked going forward in Accelerate Pro as themegrill/accelerate-pro#48 (labelled free+pro there since it affects both themes). Closing this copy to avoid duplicate tracking.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions