Problem/Motivation

TextExtractor::extractPlainText() previously rendered each field's formatter under whatever theme happened to be active at call time. Since extraction is commonly triggered from an admin route (e.g. a node's Audio tab), fields ended up rendered under the admin theme rather than the site's front-end theme — producing TTS output based on admin-theme markup/formatting instead of what visitors actually see.

This adds a new rendering_theme setting (ai_audio_generator.settings) that lets the site builder pin extraction to a specific theme. TextExtractor now switches to that theme (falling back to the site default theme when unset) via ThemeManagerInterface/ThemeInitializationInterface before rendering fields, and always restores the original active theme afterward (try/finally), including on a MissingThemeDependencyException (e.g. a broken base-theme dependency), which is caught and logged as a warning rather than blocking audio generation.

Steps to reproduce

1. Set the site's default theme and admin theme to different themes.
2. Trigger TTS extraction from an admin-only route (e.g. the node Audio tab) while the admin theme is active.
3. Observe fields are rendered/formatted per the admin theme rather than the front-end theme.

Proposed resolution

Introduce ai_audio_generator.settings:rendering_theme and switch the active theme for the duration of field rendering in extractPlainText(), restoring it afterward.

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

nnevill created an issue. See original summary.

  • nnevill committed 7806ba3d on 1.0.x
    feat: #3613805 Render TTS fields under a configurable theme instead of...
nnevill’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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.