项目作者: itravel-de

项目描述 :
Generate Thumbor URLs with Elm
高级语言: Elm
项目地址: git://github.com/itravel-de/elm-thumbor.git
创建时间: 2019-10-21T15:19:54Z
项目社区:https://github.com/itravel-de/elm-thumbor

开源协议:MIT License

下载


elm-thumbor

Build Status

Generate Thumbor URLs with Elm.

This package implements all documented Thumbor options and filters for easy use within your Elm applications.
It implements the, as of writing, current Tumbor version of 6.7.0.

This package takes some liberties in API design to make it type-safe, but tries to stay close to the original Thumbor
API naming and usage to make mapping between the official documentation as easy as possible.

Example

  1. view : Model -> Html msg
  2. view model =
  3. model.teaserImages
  4. |> List.map (\imageUrl -> img [ src (scaleTeaserImage imageUrl) ] [])
  5. |> div []
  6. scaleTeaserImage : String -> String
  7. scaleTeaserImage =
  8. thumbor
  9. [ Thumbor.sizeFixed 500 500
  10. , Thumbor.fitIn Thumbor.NormalFitIn
  11. , Thumbor.filters
  12. [ Thumbor.Filter.noUpscale
  13. , Thumbor.Filter.format Thumbor.Filter.Jpeg
  14. , Thumbor.Filter.quality 80
  15. , Thumbor.Filter.watermark
  16. { imageUrl = "https://example.com/images/watermark.png"
  17. , horizontalPosition = Thumbor.Filter.LeftPixels 10
  18. , verticalPosition = Thumbor.Filter.BottomPixels 10
  19. , alphaPercentage = 50
  20. , widthRatio = Nothing
  21. , heightRatio = Nothing
  22. }
  23. ]
  24. ]
  25. thumbor : List Thumbor.Attribute -> String -> String
  26. thumbor =
  27. Thumbor.url { baseUrl = "https://example.com", key = Just "secret" }

Security Considerations

Since Elm applications mostly run in client’s browsers directly, the key for URL signing is available in clear-text.
This nullifies the whole purpose of URL signing to make tampering impossible. This might be okay for your use-case
but you usually have to think about a better way to protect yourself from malicious Thumbor requests when you use this
package.

For details about Thumbors URL signing, see: https://thumbor.readthedocs.io/en/latest/security.html