Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
ted-crushinator-helpers
Advanced tools
JavaScript methods to produce Crushinator'd image URLs.
crushinator.crush('http://images.ted.com/image.jpg', 'w=320')
// => 'https://tedcdnpi-a.akamaihd.net/r/images.ted.com/image.jpg?w=320'
npm install ted-crushinator-helpers
bower install ted-crushinator-helpers
Code in lib/crushinator.js
can be copied to your application.
This file is in UMD and has no other dependencies, so you can import it as an AMD/CommonJS module or simply let it occupy the crushinator
namespace in your app's global.
This library provides the following methods:
For images on whitelisted domains, this method will return the URL for a crushed version of the specified image:
crushinator.crush('http://images.ted.com/image.jpg', 'w=320')
// => 'https://tedcdnpi-a.akamaihd.net/r/images.ted.com/image.jpg?w=320'
For images hosted outside Crushinator's whitelisted domains, it will simply return the original URL:
crushinator.crush('http://celly.xxx/waffles.jpg', 'w=320')
// => 'http://celly.xxx/waffles.jpg'
It will also avoid double-crushing images, and will update old Crushinator URLs to the new host:
crushinator.crush('https://tedcdnpi-a.akamaihd.net/r/images.ted.com/image.jpg?w=320', 'w=640')
// => 'https://tedcdnpi-a.akamaihd.net/r/images.ted.com/image.jpg?w=640'
crushinator.crush('https://img-ssl.tedcdn.com/r/images.ted.com/image.jpg', 'w=320')
// => 'https://tedcdnpi-a.akamaihd.net/r/images.ted.com/image.jpg?w=320'
Restore a previously crushed URL to its original form.
Note that the protocol must be borrowed from the crushed URL regardless of whether or not the host actually supports HTTPS.
crushinator.uncrush('https://tedcdnpi-a.akamaihd.net/r/images.ted.com/image.jpg?w=320')
// => 'https://images.ted.com/image.jpg'
Returns true
if the image's host is in Crushinator's whitelist, false
otherwise.
crushinator.crushable('http://images.ted.com/image.jpg')
// => true
crushinator.crushable('http://celly.xxx/waffles.jpg')
// => false
Use NVM to make sure you have the correct Node version installed for local development.
git clone git@github.com:tedconf/js-crushinator-helpers.git
nvm use
and if the required Node version is not installed on your system, nvm install <version>
npm install
npm test
will lint and test the library.
npm run build
to produce a new lib/crushinator.js
package.json
and commitgit tag
the new semverFAQs
JS methods to produce crushinator'd image URLs.
The npm package ted-crushinator-helpers receives a total of 1 weekly downloads. As such, ted-crushinator-helpers popularity was classified as not popular.
We found that ted-crushinator-helpers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.