Problem/Motivation

BookEpubAssembler::extractImagePath() resolves the mapped cover image only when the field item directly references a File entity, i.e. a plain image field. Sites managing images through core Media — increasingly the default, and universal in distributions like LocalGov Drupal — map a media reference field and silently get no cover, because the referenced entity is a Media item, not a File.

Proposed resolution

When the referenced entity is a Media item, unwrap it via its source plugin's configured source field down to the underlying File, then resolve the real path as before. The media module remains a soft dependency: instanceof MediaInterface is safely FALSE when the class does not exist, so plain image fields and media-less sites behave exactly as today.

Remaining tasks

Review; kernel test with an image field, an image-media reference, a non-image media reference (should yield no cover), and an empty field. epub_generator_localgov_publications drops its equivalent override once this lands.

User interface changes

None; a cover image mapped through Media now simply works.

API changes

None. extractImagePath() keeps its signature; behavior widens.

Data model changes

None. The one-click field installer continues to create a plain image field as its default; sites may map an existing media field instead.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

andileco created an issue. See original summary.

andileco’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • andileco committed 82e7a1fb on 1.0.x
    task: #3612026 Support Media references in the Book cover image mapping