Table of Contents
Necessary Installations (macOS)
Linking Your Site
Setting Up Large Media
Tracking Images
Post-Setup: Pointers, Not Files
On-the-Fly Resizing: The Best Part
Home Web Front-end CSS Tutorial Getting Netlify Large Media Going

Getting Netlify Large Media Going

Apr 17, 2025 am 10:17 AM

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
Copy after login

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

{
    "siteId": "xxx"
}
Copy after login

Setting Up Large Media

Run the setup command:

netlify lm:setup
Copy after login

This creates a .lfsconfig file:

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

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"
Copy after login

(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>
Copy after login

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/imghw/default1.png" data-src="https://img.php.cn/" class="lazy" alt="Getting Netlify Large Media Going ">
Copy after login
Copy after login

Combine this with responsive image techniques for optimal performance:

<img src="/static/imghw/default1.png" data-src="https://img.php.cn/" class="lazy" alt="Getting Netlify Large Media Going ">
Copy after login
Copy after login

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 of this Website
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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Vue 3 Vue 3 Apr 02, 2025 pm 06:32 PM

It&#039;s out! Congrats to the Vue team for getting it done, I know it was a massive effort and a long time coming. All new docs, as well.

Building an Ethereum app using Redwood.js and Fauna Building an Ethereum app using Redwood.js and Fauna Mar 28, 2025 am 09:18 AM

With the recent climb of Bitcoin’s price over 20k $USD, and to it recently breaking 30k, I thought it’s worth taking a deep dive back into creating Ethereum

Can you get valid CSS property values from the browser? Can you get valid CSS property values from the browser? Apr 02, 2025 pm 06:17 PM

I had someone write in with this very legit question. Lea just blogged about how you can get valid CSS properties themselves from the browser. That&#039;s like this.

Stacked Cards with Sticky Positioning and a Dash of Sass Stacked Cards with Sticky Positioning and a Dash of Sass Apr 03, 2025 am 10:30 AM

The other day, I spotted this particularly lovely bit from Corey Ginnivan’s website where a collection of cards stack on top of one another as you scroll.

A bit on ci/cd A bit on ci/cd Apr 02, 2025 pm 06:21 PM

I&#039;d say "website" fits better than "mobile app" but I like this framing from Max Lynch:

Comparing Browsers for Responsive Design Comparing Browsers for Responsive Design Apr 02, 2025 pm 06:25 PM

There are a number of these desktop apps where the goal is showing your site at different dimensions all at the same time. So you can, for example, be writing

Using Markdown and Localization in the WordPress Block Editor Using Markdown and Localization in the WordPress Block Editor Apr 02, 2025 am 04:27 AM

If we need to show documentation to the user directly in the WordPress editor, what is the best way to do it?

Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Apr 05, 2025 pm 05:51 PM

Questions about purple slash areas in Flex layouts When using Flex layouts, you may encounter some confusing phenomena, such as in the developer tools (d...

See all articles