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

fix: support fallback for media src #1490

Merged
merged 5 commits into from
Jan 22, 2025
Merged

Conversation

srijitcoder
Copy link
Member

@srijitcoder srijitcoder commented Jan 17, 2025

Implemented Changes

Problem

When uploading media using the GitHub API in git-clerk, we can only use its permanent URL. This ensures the media is always accessible, even if the branch is merged or deleted. However, the permanent URL becomes available to users only after a delay of one minute.

Solution

  • Utilize the commit URL as a fallback src. While the commit URL is not suitable for permanent purposes, it is available immediately after merging. This allows the image to be loaded into storytelling until the permanent URL is ready. (This ensures users can view the image without delay.)
  • To achieve this, we use the attribute data-fallback-src="" property to load the backup URL, as shown below:
<img src="permanent-src" data-fallback-src="temporary-fallback-src"
  • If any normal image don't load a default fallback-src will be loaded - https://placehold.co/600x400?text=Media+not+found

Screenshots/Videos

Checklist before requesting a review

Copy link

netlify bot commented Jan 17, 2025

Deploy Preview for eoxelements ready!

Name Link
🔨 Latest commit d1bc14c
🔍 Latest deploy log https://app.netlify.com/sites/eoxelements/deploys/6790c64c22f2b70008edd486
😎 Deploy Preview https://deploy-preview-1490--eoxelements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@srijitcoder srijitcoder changed the title Fix: Tweak for permanent url image availability delay using temporary backup url Fix: Tweak for permanent url availability delay using temporary backup url Jan 17, 2025
@srijitcoder srijitcoder added bug Something isn't working storytelling labels Jan 17, 2025
@srijitcoder srijitcoder marked this pull request as ready for review January 17, 2025 09:02
@silvester-pari silvester-pari changed the title Fix: Tweak for permanent url availability delay using temporary backup url fix: fallback for media src Jan 22, 2025
@silvester-pari silvester-pari merged commit 8c40fdd into main Jan 22, 2025
7 checks passed
@silvester-pari silvester-pari deleted the storytelling/fix/img-load-fix branch January 22, 2025 10:27
@silvester-pari silvester-pari changed the title fix: fallback for media src fix: support fallback for media src Jan 22, 2025
@github-actions github-actions bot mentioned this pull request Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working storytelling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants