Skip to content

feat: thumbnail image custom styles #232

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

Merged

Conversation

jarod-legault
Copy link
Contributor

Summary

There is now a new customStyles property that can be passed to the video player component: thumbnailImage. This is required because react-native-video-player uses the ImageBackground component from react-native to render the thumbnail image. The ImageBackground component has two separate props for styles: style and imageStyle. The resizeMode can only be passed to the ImageBackground component via the imageStyle prop, not the style prop (as it was being passed previously).

NOTE: When using the react-native-video-player component in my app, I noticed that currently TypeScript incorrectly reports that the type of customStyles.thumbnail is ImageStyle, but it is actually defined as ViewStyle in index.tsx. I think that maybe the index.d.ts file needs to be generated again in order to make sure the types are correct in the npm package.

fixes #231

Motivation

When I was using react-native-video-player in my app, I noticed that when I passed resizeMode via the customStyles.thumbnail prop, the resizeMode was not being applied.

Changes

  • Added a customStyles.thumbnailImage property and passed this to the Thumbnail ImageBackground component as imageStyle prop.
  • Updated docs with the new customStyle.thumbnailImage property.
  • Added customStyles.thumbnailImage to example app (resizeMode: 'cover').
  • Also fixed conflicting variable name width in onLayout function in src/index.ts.

Test plan

To manually test, run the example app and notice that the thumbnail covers the entire video container:

resizeMode - cover

Then change customStyles.thumbnailImage.resizeMode to "contain", and notice that the thumbnail no longer covers the entire container:

resizeMode - contain

I don't think an automated test is required for this change.

…#231)

- Required in order to be able to apply a `resizeMode` style to the video thumbnail.
- `ImageBackground` component has a separate `style` prop and `imageStyle` prop.
- The `resizeMode` property can only be applied via the `imageStyle` prop.
- Updated docs with the new `customStyle.thumbnailImage` property.
- Also fixed duplicate variable name `width` in `onLayout` function.
- Added `customStyles.thumbnailImage` to example app.
@jarod-legault
Copy link
Contributor Author

@moskalakamil Just following up on this to see if you are ok with the fix.

@moskalakamil moskalakamil changed the title Fix Thumbnail ResizeMode feat: thumbnail image custom styles May 5, 2025
@moskalakamil moskalakamil merged commit 8ab379b into TheWidlarzGroup:master May 5, 2025
5 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.

[BUG]: customStyles.thumbnail.resizeMode doesn't work on Android.
2 participants