Skip to content

[5.x]: asset.render() gives Error: Call to a member function getHandle() on null #15426

@JeroenJRP

Description

@JeroenJRP

What happened?

Description

When tying to call the render() function on an Asset element, an error is thrown

Steps to reproduce

  1. Query an Asset from twig
  2. Call .render() on the query or resulting element

Expected behavior

Asset is rendered using the corosponding partial

Actual behavior

The error "Call to a member function getHandle() on null" is thrown. This is because the provider for the Asset's FieldLayout is null

Craft CMS version

5.2.8 (upgraded from 4.10.6)

PHP version

8.3

Operating system and version

No response

Database type and version

MariaDB 10.6.18

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions