Gathering detailed insights and metrics for @vtex/gatsby-plugin-thumbor
Gathering detailed insights and metrics for @vtex/gatsby-plugin-thumbor
Gathering detailed insights and metrics for @vtex/gatsby-plugin-thumbor
Gathering detailed insights and metrics for @vtex/gatsby-plugin-thumbor
Digital commerce toolkit for frontend developers
npm install @vtex/gatsby-plugin-thumbor
Typescript
Module System
Min. Node Version
Node Version
NPM Version
22.7
Supply Chain
54.4
Quality
74.3
Maintenance
25
Vulnerability
90.7
License
Fixes in the Breadcrumb
Updated on Mar 10, 2025
Introducing SKUMatrix Component
Updated on Jan 15, 2025
FastStore: Improved search query with the `sponsoredCount` parameter
Updated on Dec 19, 2024
FastStore v3.0.123: Renaming `faststore.config` to `discovery.config`
Updated on Oct 07, 2024
FastStore v3.0.117: Integration between FastStore and VTEX Ad Network
Updated on Oct 03, 2024
FastStore v3.0.97: Package fixes
Updated on Sep 03, 2024
TypeScript (78.9%)
SCSS (18.27%)
JavaScript (2.83%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
201 Stars
5,120 Commits
67 Forks
91 Watchers
354 Branches
112 Contributors
Updated on Jul 16, 2025
Latest Version
1.5.21-avon.0
Package Id
@vtex/gatsby-plugin-thumbor@1.5.21-avon.0
Unpacked Size
96.41 kB
Size
20.29 kB
File Count
29
NPM Version
lerna/3.22.1/node@v14.20.0+x64 (linux)
Node Version
14.20.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
A plugin for integrating gatsby-plugin-image with thumbor, an open-source smart on-demand image cropping, resizing and filters, so you can make your own smart image handling service.
yarn add @vtex/gatsby-plugin-thumbor gatsby-plugin-image
For using this plugin, you will need to add both gatsby-plugin-image
and gatsby-plugin-thumbor
to your gatsby-config.js
.
1// In your gatsby-config.js 2module.exports = { 3 plugins: [ 4 // other plugins ... 5 { 6 resolve: 'gatsby-plugin-image' 7 }, 8 { 9 resolve: `@vtex/gatsby-plugin-thumbor` 10 options: { 11 // Your thumbor server url 12 server: 'https://mythumborserver.com', 13 } 14 } 15 ], 16}
Then, in your react component you can simply use the hooks exported by gatsby-plugin-thumbor
with the components exported by gatsby-plugin-image
1// In your React component 2import React, { FC } from 'react' 3import { useThumborImageData } from '@vtex/gatsby-plugin-thumbor' 4import { GatsbyImage } from 'gatsby-plugin-image' 5 6const MyComponent: FC = () => { 7 const image = useThumborImageData({ 8 baseUrl: 'http://example.org/image.jpg', 9 options: { 10 // ...other thumbor options 11 fitIn: true, 12 } 13 }) 14 15 return <GatsbyImage alt="example image" image={image} /> 16}
Thumbor is an image processing service that enables you to process any image on the web. According to gatsby-plugin-image
documentation, thumbor is a URL-based image optimization service. This means that, for processing an image, we only need to generate an URL with the right parameters, and thumbor will do the heavy lifting for us.
A thumbor compatible URL can be split into two sections. The first one is a thumbor specific URL with parameters for image resizing, postprocessing, etc, and a second section containing a data source where thumbor must fetch the original image from. To illustrate. Let's suppose your thumbor service is located at mythumborserver.com
domain and that you need to resize to 250px/250px an image located at example.com/image.png
. To resize image.png
you can do the following request:
GET https://mythumborserver.com/unsafe/250x250/http://example.com/image.png
The aforementioned request returns the processed image. gatsby-plugin-image
uses this URL in HTML's img
tag elements to add images to the final HTML.
As mentioned before, Thumbor has lots of different parameters that tell it how to process and convert images. gatsby-plugin-thumbor
tightly integrates with gatsby-plugin-image
to give you control over these parameters in a simple interface, while generating a thumbor compatible URLs. The interface chosen is the extra options
parameters in gatsby-plugin-image
functions.
You may now be wondering why there is an /unsafe
segment in thumbor's generated URL. This is because thumbor accepts requests from anyone on the internet to process and resize images. This makes the thumbor service prone to DDoS attacks.
Thumbor has a solution for this on their docs. They say you should sign the URLs so the thumbor service knows when an image is from a reliable source or if it's someone messing with your server. This is the best way for protecting your thumbor server.
However, this plugin offers an alternative to this solution.
Usually, when serving gatsby, you are using a CDN (gatsby-plugin-netlify
) or Nginx (@vtex/gatsby-plugin-nginx
). These services can be used as a reverse proxy server. Adding a reverse proxy to your thumbor service may protect it from malicious users because then we can only allow a small subset of all possible transformations to your images, decreasing the attack space on your thumbor service.
This protection is achieved with two parameters accepted by the plugin, sizes
and basePath
. A config using these parameters looks like this:
1// In your gatsby-config.js 2module.exports = { 3 plugins: [ 4 // other plugins ... 5 { 6 resolve: 'gatsby-plugin-image' 7 }, 8 { 9 resolve: `@vtex/gatsby-plugin-thumbor` 10 options: { 11 // Your thumbor server url 12 server: 'https://mythumborserver.com', 13 basePath: '/images', 14 sizes: [ 15 '1080x1080', 16 '720x720', 17 ] 18 } 19 } 20 ], 21}
Now, instead of creating URLs like https://mythumborserver.com/unsafe/1080x1080/http://example.com/image.png
, the plugin will create URLs for {basePath}/1080x1080/http://example.com/image.png
, serve thumbor images on the same domain as your site, and will only allow resizing to 1080x1080 and 720x720 images.
Behind the scenes, what this plugin is doing is calling a createRedirect
function between /{basePath}/{size} => https://mythumborserver.com/unsafe/{size}
Aside from useThumborImageData
, this plugin exports useUrlBuilder
, useGetThumborImageData
, getThumborImageData
and urlBuilder
. These functions are thin wrappers to their counterparts on gatsby-plugin-image
only adding the plugin's options, like the thumbor server URL. You can use them normally in your react code. For instance, if you need the getImageData
function you can:
1// In your React component
2import React, { FC } from 'react'
3import { useGetThumborImageData } from '@vtex/gatsby-plugin-thumbor'
4import { GatsbyImage, withArtDirection } from 'gatsby-plugin-image'
5
6const MyComponent: FC = () => {
7 // gatsby-plugin-image's getImageData function
8 const getImageData = useGetThumborImageData()
9 const img1 = getImageData({baseUrl: 'http://example.org/img1.jpg'})
10 const img2 = getImageData({baseUrl: 'http://example.org/img2.jpg'})
11
12 // The images are totally compatible with gatsby-plugin-image
13 const image = withArtDirection(img1, {
14 media: '(max-width: 40em)',
15 image: img2
16 })
17
18 return <GatsbyImage alt="example image" image={image} />
19}
Feel free to open issues in our repo. Also, there is a general contributing guideline in there
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool is run on all commits
Details
Reason
Found 15/30 approved changesets -- score normalized to 5
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
28 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More