Skip to content

Use featured image as player artwork fallback #843#897

Merged
zahardev merged 2 commits intodevelopfrom
version/3.16.0-support-player-featured-image
May 5, 2026
Merged

Use featured image as player artwork fallback #843#897
zahardev merged 2 commits intodevelopfrom
version/3.16.0-support-player-featured-image

Conversation

@zahardev
Copy link
Copy Markdown
Collaborator

@zahardev zahardev commented May 4, 2026

Summary

  • Add post featured image as a fallback in get_album_art() after cover/series/feed images and before the placeholder
  • Skip squareness check for the featured image — the HTML5 player handles non-square via CSS
  • Resolves CastosHQ/ssp-issues#843

Test plan

  • Verify episode with featured image (no cover/series/feed image) shows featured image in player instead of placeholder
  • Verify episode with cover image still shows cover image (not featured image)
  • Verify episode with no images at all still shows placeholder
  • Run vendor/bin/codecept run WPUnit EpisodeRepositoryAlbumArtTest — 4 tests pass

Summary by CodeRabbit

  • Bug Fixes

    • Album art selection now falls back to the episode’s featured image when primary sources don’t provide artwork, and no longer requires featured images to be square.
  • Tests

    • Added unit tests covering album art selection: featured-image fallback, preference when alternate cover exists, non-square featured images, and placeholder fallback.

Falls back to the post's featured image in get_album_art() after
cover/series/feed images and before the placeholder. Skips the
squareness check since the HTML5 player handles non-square via CSS.

Co-Authored-By: Claude via AIContext
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bb8ae0de-e81d-4bc5-8a2f-ab3e0b376de3

📥 Commits

Reviewing files that changed from the base of the PR and between 7729566 and 07ccf1d.

📒 Files selected for processing (1)
  • tests/WPUnit/EpisodeRepositoryAlbumArtTest.php
✅ Files skipped from review due to trivial changes (1)
  • tests/WPUnit/EpisodeRepositoryAlbumArtTest.php

📝 Walkthrough

Walkthrough

get_album_art() in the Episode Repository adds a new fallback to use the episode's featured image (post thumbnail) without requiring square aspect ratio; it returns the thumbnail only when the attachment image src is non-empty. The "no album art" placeholder is attempted after this new fallback. A new PHPUnit test class validates these behaviors.

Changes

Album Art Fallback Enhancement

Layer / File(s) Summary
Core Logic
php/classes/repositories/class-episode-repository.php
get_album_art() gains a new fallback (Option 5) that attempts to use the post featured image (thumbnail) without checking for squareness; it returns the attachment image data only if the src is non-empty. The existing "no album art" fallback is moved to a later position (Option 6).
Tests / Validation
tests/WPUnit/EpisodeRepositoryAlbumArtTest.php
New test class EpisodeRepositoryAlbumArtTest added with helpers createEpisode() and createAttachment() and four tests: returns featured image when no other images exist; prefers square cover_image_id over featured; accepts non-square featured images; returns placeholder (no-album-art) when no featured image exists.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

"I hopped through code and found a spare,
A thumbnail saved from the blank-stare,
Tests nibble bugs with careful art,
Now episodes wear a proper heart 🐇"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding the featured image as a fallback option in the album art selection logic, which is the primary objective of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch version/3.16.0-support-player-featured-image

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.1.54)

PHPStan was skipped because the sandbox runner could not parse its output.


Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/WPUnit/EpisodeRepositoryAlbumArtTest.php`:
- Around line 79-82: The tests currently only assert $result is an array and its
src is not the placeholder; update the assertions in
EpisodeRepositoryAlbumArtTest (both the block around the existing
$this->assertIsArray/$this->assertNotEmpty/$this->assertStringNotContainsString
and the similar block at 117-121) to verify the selected image is the actual
featured image: fetch the expected featured image identifier or URL from the
test fixture (e.g. the post's featured image ID or its URL used to set up the
post), then assert equality between that expected value and $result['src'] (or
$result['attachment_id'] if that key is present) using $this->assertEquals to
ensure the returned src matches the real featured image rather than merely not
being the placeholder.
- Around line 14-18: In setUp() of EpisodeRepositoryAlbumArtTest reset the
global feed-image option so tests won't be affected by external state: call the
WordPress option reset (e.g., update_option('ss_podcasting_data_image', '') or
delete_option('ss_podcasting_data_image')) inside the setUp() method right after
obtaining $this->episode_repository so get_album_art() behavior is
deterministic; reference the setUp() method and the ss_podcasting_data_image
option/get_album_art() check when making the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cd71bfc6-85b4-4955-85c8-ec32bc746e21

📥 Commits

Reviewing files that changed from the base of the PR and between 11ea64e and 7729566.

📒 Files selected for processing (2)
  • php/classes/repositories/class-episode-repository.php
  • tests/WPUnit/EpisodeRepositoryAlbumArtTest.php

Comment thread tests/WPUnit/EpisodeRepositoryAlbumArtTest.php
Comment thread tests/WPUnit/EpisodeRepositoryAlbumArtTest.php
@zahardev zahardev merged commit 5e594a1 into develop May 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant