search
HomeWeb Front-endCSS TutorialGetting Netlify Large Media Going

Getting Netlify Large Media Going

Recently, I tackled setting up Netlify Large Media, and thought I'd share my experience. Git Large File Storage (Git LFS) is key here: it keeps large files out of your main Git repository. Imagine a website with 500MB of images – including them directly in the repo makes cloning a nightmare. Git LFS solves this by storing large files separately.

Netlify Large Media builds upon Git LFS, simplifying setup and adding a crucial benefit: on-the-fly image resizing via URL parameters. This automated resizing is a huge time-saver.

While the official documentation is a good starting point, I encountered a few hurdles, which I'll document below.

Necessary Installations (macOS)

These steps are for macOS; adjust as needed for other systems. You'll require:

  1. Git LFS: brew install git-lfs
  2. Netlify CLI: npm install netlify-cli -g
  3. Netlify Large Media Plugin: netlify plugins:install netlify-lm-plugin followed by netlify lm:install

Linking Your Site

Authenticate with Netlify to connect the CLI to your project:

netlify link

This generates a .netlify/state.json file containing your site ID:

{
    "siteId": "xxx"
}

Setting Up Large Media

Run the setup command:

netlify lm:setup

This creates a .lfsconfig file:

<code>[lfs]
    url = https://xxx.netlify.com/.netlify/large-media</code>

Commit both .netlify/state.json and .lfsconfig.

Tracking Images

Use Git LFS to specify which image types should be managed:

git lfs track "*.jpg" "*.jpeg" "*.png"

(Note: I initially missed .jpeg, leading to issues. Ensure you include all relevant extensions.)

This generates a .gitattributes file, for example:

<code>*.jpg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text</code>

After committing and pushing, your images will upload to Netlify Large Media. This push might take a while, depending on file size.

A potential snag: My initial push stalled. The solution was installing the netlify-credential-helper.

This process isn't limited to images; any large binary file can be handled this way.

Post-Setup: Pointers, Not Files

After the initial push, your repository will contain only pointers to the files stored in Netlify Large Media.

On-the-Fly Resizing: The Best Part

Resize images dynamically using URL parameters:

<img src="/static/imghwm/default1.png" data-src="https://img.php.cn/?x-oss-process=image/resize,p_40" class="lazy" alt="Getting Netlify Large Media Going ">

Combine this with responsive image techniques for optimal performance:

<img src="/static/imghwm/default1.png" data-src="https://img.php.cn/?x-oss-process=image/resize,p_40" class="lazy" alt="Getting Netlify Large Media Going ">

The above is the detailed content of Getting Netlify Large Media Going. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
A Little Reminder That Pseudo Elements are Children, Kinda.A Little Reminder That Pseudo Elements are Children, Kinda.Apr 19, 2025 am 11:39 AM

Here's a container with some child elements:

Menus with 'Dynamic Hit Areas'Menus with 'Dynamic Hit Areas'Apr 19, 2025 am 11:37 AM

Flyout menus! The second you need to implement a menu that uses a hover event to display more menu items, you're in tricky territory. For one, they should

Improving Video Accessibility with WebVTTImproving Video Accessibility with WebVTTApr 19, 2025 am 11:27 AM

"The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."- Tim Berners-Lee

Weekly Platform News: CSS ::marker pseudo-element, pre-rendering web components, adding Webmention to your siteWeekly Platform News: CSS ::marker pseudo-element, pre-rendering web components, adding Webmention to your siteApr 19, 2025 am 11:25 AM

In this week's roundup: datepickers are giving keyboard users headaches, a new web component compiler that helps fight FOUC, we finally get our hands on styling list item markers, and four steps to getting webmentions on your site.

Making width and flexible items play nice togetherMaking width and flexible items play nice togetherApr 19, 2025 am 11:23 AM

The short answer: flex-shrink and flex-basis are probably what you’re lookin’ for.

Position Sticky and Table HeadersPosition Sticky and Table HeadersApr 19, 2025 am 11:21 AM

You can't position: sticky; a

Weekly Platform News: HTML Inspection in Search Console, Global Scope of Scripts, Babel env Adds defaults QueryWeekly Platform News: HTML Inspection in Search Console, Global Scope of Scripts, Babel env Adds defaults QueryApr 19, 2025 am 11:18 AM

In this week's look around the world of web platform news, Google Search Console makes it easier to view crawled markup, we learn that custom properties

IndieWeb and WebmentionsIndieWeb and WebmentionsApr 19, 2025 am 11:16 AM

The IndieWeb is a thing! They've got a conference coming up and everything. The New Yorker is even writing about it:

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment