项目作者: Brettm12345

项目描述 :
A typescript client for using thumbor urls in gatsby-image using react hooks
高级语言: TypeScript
项目地址: git://github.com/Brettm12345/thumbor-gatsby-image.git
创建时间: 2019-10-28T16:11:51Z
项目社区:https://github.com/Brettm12345/thumbor-gatsby-image

开源协议:

下载


Thumbor TS Gatsby Image

Auto convert thumbor-ts instances into gatsby-image compatible objects

Usage

  1. import React, { FC } from "react";
  2. import Img from "gatsby-image";
  3. import { useFixed } from "thumbor-ts-gatsby-image";
  4. import { Thumbor } from "thumbor-ts";
  5. // Your encryption key is not required, but your link will be unsafe.
  6. const thumbor = Thumbor({
  7. serverUrl: "http://myserver.thumbor.com",
  8. securityKey: "MY_KEY"
  9. });
  10. const image = thumbor.setImagePath("00223lsvrnzeaf42.png").smartCrop(true);
  11. const Img: FC = () => {
  12. const fixed = useFixed(image, { width: 200, height: 300 });
  13. return <Img fixed={fixed} />;
  14. };