Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for mediaDetails and featured images to Cover/MediaText #47

Merged
merged 2 commits into from
Dec 25, 2024

Conversation

justlevine
Copy link
Collaborator

What

This PR:

  • exposes the mediaDetails field to the CoreCover and CoreMediaText objects.
  • fixes the connectedMediaItem when handling CoreCover or CoreMediaText blocks that useFeaturedImage.

Why

Shim until we can fix this for real in WPGraphQL Content Blocks

Related Issue(s):

Part of https://github.com/rtCamp/headless/issues/228

How

Important

Only mediaDetails and connectedMediaItem support Featured Images.
Hydrating the Core{Cover|MediaText}Attributes fields can only be done in WPGraphQL Content Blocks. (After #25).

Testing Instructions

query GetTemplate($uri: String!) {
  templateByUri(uri: $uri) {
    editorBlocks {
      ... on CoreMediaText { # or ... on CoreCover
        attributes {
          useFeaturedImage
          ...MyAttributesFrag
        }
        mediaDetails {
         ...MyMediaDetailsFrag
        }
        connectedMediaItem {
          node {
            ...MyConnectedMediaItemNodeFrag
          }
        }
      }
    }
  }
}


## Screenshots
<!-- Include relevant screenshots proving the PR works as indended. -->

## Additional Info
<!-- Please include any relevant logs, error output, etc -->

Unit tests have _not_ been included, since this is a temporary shim. The functionality is smoke-tested in the frontend block components.

## Checklist
<!-- We encourage you to complete this checklist to the best of your abilities. If you can't do everything, that's okay too. -->
- [x] I have read the [Contribution Guidelines](../DEVELOPMENT.md).
- [x] My code is tested to the best of my abilities.
- [x] My code passes all lints (PHPCS, PHPStan, ESLint, etc). <!-- See the Contributing Guidelines for linting instructions -->
- [x] My code has detailed inline documentation. <!-- Guidelines: https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/ -->
- [ ] I have added unit tests to verify the code works as intended.
- [x] I have updated the project documentation accordingly.

@justlevine justlevine requested a review from SH4LIN December 23, 2024 21:23
@justlevine
Copy link
Collaborator Author

connectedMediaItem fixed:

image

@justlevine justlevine merged commit f97ea57 into develop Dec 25, 2024
8 checks passed
@justlevine justlevine deleted the feat/mediaDetails-featuredImage-blocks branch December 25, 2024 16:06
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