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(gatsby-remark-copy-linked-files): add support for video elements with src attribute #10395

Conversation

janmonschke
Copy link
Contributor

This adds support for video elements that only have a src attribute.

<video src="myvideo.mp4"></video>

@@ -234,7 +234,7 @@ module.exports = (

// Handle video tags.
const videoRefs = []
$(`video source`).each(function() {
$(`video source, video`).each(function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about:

Suggested change
$(`video source, video`).each(function() {
$(`video source[src], video[src]`).each(function() {

to target elements that actually have src attribute?

With video source, video selector we would push a lot of undefined to videoRefs array:

<video>
  <source type="video/mp4" src="video.mp4"></source>
</video>

outer <video> would be targeted by selector, but it doesn't have src so it doesn't make sense to push it to array, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, that's a great idea. I looked at the code again and saw that there is quite some duplication in that file. Would you be open if I refactor that file a bit?

Copy link
Contributor

Choose a reason for hiding this comment

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

Absolutely open to that! After you mentioned it I just did quick browse of entire file (instead of just zooming in on area your changes) and see that the handling of video, audio and anchor tags is essentially copy'n'pasted and could be DRYed a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed a lot of duplicated code in 6efd3c3 and then added the attributes to the selector as you proposed in 067d453.

@pieh pieh changed the title [gatsby-remark-copy-linked-files] add support for video elements with src attribute feat(gatsby-remark-copy-linked-files): add support for video elements with src attribute Dec 13, 2018
@pieh pieh self-assigned this Dec 17, 2018
Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

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

Thanks for feature and refactor @janmonschke!

@pieh pieh merged commit 4ceb0f8 into gatsbyjs:master Dec 17, 2018
@gatsbot
Copy link

gatsbot bot commented Dec 17, 2018

Holy buckets, @janmonschke — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (Currently we’ve got a couple t-shirts available, plus some socks that are really razzing our berries right now.)
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

m-allanson added a commit to lipis/gatsby that referenced this pull request Dec 17, 2018
* master: (1037 commits)
  Update starters.yml (gatsbyjs#10505)
  chore(release): Publish
  fix(graphql-skip-limit): fix hasNextPage (gatsbyjs#10504)
  chore: use cjs instead of esm for consistency (gatsbyjs#10494)
  feat(gatsby-remark-copy-linked-files): add support for video elements with `src` attribute (gatsbyjs#10395)
  typofix (gatsbyjs#10488)
  Add kobit.in to showcase (gatsbyjs#10496)
  fix(docs): window.reload => window.location.reload (gatsbyjs#10459)
  feat(www): add unbird feedback component to starter lib (gatsbyjs#10450)
  fix(blog): youfit case study typofix
  Doc improvements to Visual testing with Storybook guide (gatsbyjs#10436)
  fix(gatsby-plugin-offline): prevent incorrect revisioning of static file by workbox (gatsbyjs#10416)
  fix(starters): ttag repo link
  fix typo in pull request template (gatsbyjs#10454)
  fix(www) Fix query for plugin links always ?=undefined (gatsbyjs#10453)
  chore(release): Publish
  fix(gatsby): fix extracting StaticQuery nested in shorthand fragment (gatsbyjs#10443)
  fix(www): avoid querying for no-cache=1 (gatsbyjs#10389)
  fix(gatsby-image): update typescript definitions - properly mark fields as optional (gatsbyjs#10419)
  refactor(gatsby): improve EnsureResources (gatsbyjs#10224)
  ...
wconnorwalsh added a commit to wconnorwalsh/gatsby that referenced this pull request Dec 17, 2018
* master:
  docs: add ibm case study blog post (gatsbyjs#10474)
  Update sites.yml (gatsbyjs#10512)
  Update starters.yml (gatsbyjs#10505)
  chore(release): Publish
  fix(graphql-skip-limit): fix hasNextPage (gatsbyjs#10504)
  chore: use cjs instead of esm for consistency (gatsbyjs#10494)
  feat(gatsby-remark-copy-linked-files): add support for video elements with `src` attribute (gatsbyjs#10395)
  typofix (gatsbyjs#10488)
  Add kobit.in to showcase (gatsbyjs#10496)
  fix(docs): window.reload => window.location.reload (gatsbyjs#10459)

# Conflicts:
#	packages/gatsby/CHANGELOG.md
#	packages/gatsby/package.json
gpetrioli pushed a commit to gpetrioli/gatsby that referenced this pull request Jan 22, 2019
… with `src` attribute (gatsbyjs#10395)

This adds support for video elements that only have a `src` attribute.

```html
<video src="myvideo.mp4"></video>
```
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.

2 participants