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

Using relative URLs to refer to audio/video/font files #5727

Closed
wbamberg opened this issue Mar 22, 2022 · 9 comments · Fixed by #7605
Closed

Using relative URLs to refer to audio/video/font files #5727

wbamberg opened this issue Mar 22, 2022 · 9 comments · Fixed by #7605
Assignees
Labels
idle interactive-examples issues related to interactive examples (EmbedInteractiveExample macro) p2 We want to address this but may have other higher priority items. wx writer experience

Comments

@wbamberg
Copy link
Collaborator

In mdn/content#14183 I want to include a live sample using an <audio> element. With, <img> elements I can download the source, keep it alongside index.md, and reference it using a relative path, like this: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img#alternative_text.

I don't seem to be able to do the same with audio files (and maybe video too, haven't tried these). I need to refer to them using an absolute URL, like https://pr14183.content.dev.mdn.mozit.cloud/en-US/docs/Web/API/HTMLMediaElement/preservespitch#example . This doesn't seem ideal - it would be good to keep all the assets for a page together.

@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Mar 22, 2022
@github-actions github-actions bot added the 🐌 idle Issues and PRs without recent activity. Flagged for maintainer follow-up. label May 28, 2022
@wbamberg
Copy link
Collaborator Author

wbamberg commented Jun 3, 2022

I think the same applies to .ttf, which is forcing us to use a GitHub Pages-hosted example for https://developer.mozilla.org/en-US/docs/web/css/@font-face#specifying_a_downloadable_font .

I might be wrong here though.

@caugner
Copy link
Contributor

caugner commented Aug 29, 2022

The magic for images (img[src]) is happening here:

yari/build/index.js

Lines 462 to 463 in 68d8fa1

// Check and scrutinize any local image references
const fileAttachments = checkImageReferences(doc, $, options, document);

const matches = [
...findMatchesInText(src, rawContent, {
attribute: "src",
}),
];

The same approach should work for audio[src], but it will be slightly trickier to extract fonts as well.

@caugner

This comment was marked as outdated.

@hamishwillee
Copy link
Contributor

hamishwillee commented Sep 1, 2022

Yes. Also font files like woff and woff2. Can we get these supported too @caugner ?

@caugner
Copy link
Contributor

caugner commented Sep 2, 2022

Yes. Also font files like woff and woff2.

That will definitely be trickier, because you wouldn't be referencing those fonts in an HTML attribute, but rather inline in JavaScript or in a <style> tag. 🤔

@hamishwillee Would those woff/woff2 files be used in multiple examples?

@hamishwillee
Copy link
Contributor

hamishwillee commented Sep 5, 2022

@caugner Yes. For my case I'll be accessing them programmatically using FontFace - that means it's a fetch under the hood, which is why I need this same-site.
But yes, also handy in styles via @font-face.

@hamishwillee Would those woff/woff2 files be used in multiple examples?

Yes. At least the FontFace and @font-face examples.

There are some alternatives that might be used.

  • Work out how to serve this kind of file from Google Fonts. I have not succeeded with this.
  • Our own CDN for serving these files.

But having these locally is the most flexible solution, and means we won't have to hassle you again.

@caugner caugner self-assigned this Nov 7, 2022
@caugner caugner added p2 We want to address this but may have other higher priority items. interactive-examples issues related to interactive examples (EmbedInteractiveExample macro) and removed 🐌 idle Issues and PRs without recent activity. Flagged for maintainer follow-up. needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Nov 7, 2022
@caugner caugner changed the title Using relative URLs to refer to audio files (and video probably) Using relative URLs to refer to audio/video/font files Nov 7, 2022
@caugner caugner added the wx writer experience label Nov 14, 2022
@Rumyra

This comment was marked as off-topic.

@hamishwillee

This comment was marked as off-topic.

@Rumyra

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idle interactive-examples issues related to interactive examples (EmbedInteractiveExample macro) p2 We want to address this but may have other higher priority items. wx writer experience
Projects
Development

Successfully merging a pull request may close this issue.

4 participants