mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-23 14:15:33 +03:00
Use cloudinary image for author image.
This commit is contained in:
parent
68b80728fd
commit
d00f326f5c
@ -1,5 +1,6 @@
|
||||
module Data.Author exposing (Author, all, decoder, view)
|
||||
|
||||
import Cloudinary
|
||||
import Element exposing (Element)
|
||||
import Html.Attributes as Attr
|
||||
import Json.Decode as Decode exposing (Decoder)
|
||||
@ -18,7 +19,7 @@ type alias Author =
|
||||
all : List Author
|
||||
all =
|
||||
[ { name = "Dillon Kearns"
|
||||
, avatar = Pages.images.author.dillon
|
||||
, avatar = Cloudinary.url "v1602899672/elm-radio/dillon-profile_n2lqst.jpg" Nothing 140
|
||||
, bio = "Elm developer and educator. Founder of Incremental Elm Consulting."
|
||||
}
|
||||
]
|
||||
|
@ -1,5 +1,6 @@
|
||||
module Main exposing (main)
|
||||
|
||||
import Cloudinary
|
||||
import Color
|
||||
import Data.Author as Author
|
||||
import Date
|
||||
@ -83,35 +84,8 @@ cloudinaryIcon :
|
||||
MimeType.MimeImage
|
||||
-> Int
|
||||
-> ImagePath pathKey
|
||||
cloudinaryIcon format width =
|
||||
let
|
||||
base =
|
||||
"https://res.cloudinary.com/dillonkearns/image/upload"
|
||||
|
||||
asset =
|
||||
"v1603234028/elm-pages/elm-pages-icon"
|
||||
|
||||
fetch_format =
|
||||
case format of
|
||||
MimeType.Png ->
|
||||
"png"
|
||||
|
||||
MimeType.OtherImage "webp" ->
|
||||
"webp"
|
||||
|
||||
_ ->
|
||||
"auto"
|
||||
|
||||
transforms =
|
||||
[ "c_pad"
|
||||
, "w_" ++ String.fromInt width
|
||||
, "h_" ++ String.fromInt width
|
||||
, "q_auto"
|
||||
, "f_" ++ fetch_format
|
||||
]
|
||||
|> String.join ","
|
||||
in
|
||||
ImagePath.external (base ++ "/" ++ transforms ++ "/" ++ asset)
|
||||
cloudinaryIcon mimeType width =
|
||||
Cloudinary.url "v1603234028/elm-pages/elm-pages-icon" (Just mimeType) width
|
||||
|
||||
|
||||
type alias View =
|
||||
|
40
src/Cloudinary.elm
Normal file
40
src/Cloudinary.elm
Normal file
@ -0,0 +1,40 @@
|
||||
module Cloudinary exposing (..)
|
||||
|
||||
import MimeType
|
||||
import Pages.ImagePath as ImagePath exposing (ImagePath)
|
||||
|
||||
|
||||
url :
|
||||
String
|
||||
-> Maybe MimeType.MimeImage
|
||||
-> Int
|
||||
-> ImagePath pathKey
|
||||
url asset format width =
|
||||
let
|
||||
base =
|
||||
"https://res.cloudinary.com/dillonkearns/image/upload"
|
||||
|
||||
fetch_format =
|
||||
case format of
|
||||
Just MimeType.Png ->
|
||||
"png"
|
||||
|
||||
Just (MimeType.OtherImage "webp") ->
|
||||
"webp"
|
||||
|
||||
Just _ ->
|
||||
"auto"
|
||||
|
||||
Nothing ->
|
||||
"auto"
|
||||
|
||||
transforms =
|
||||
[ "c_pad"
|
||||
, "w_" ++ String.fromInt width
|
||||
, "h_" ++ String.fromInt width
|
||||
, "q_auto"
|
||||
, "f_" ++ fetch_format
|
||||
]
|
||||
|> String.join ","
|
||||
in
|
||||
ImagePath.external (base ++ "/" ++ transforms ++ "/" ++ asset)
|
Loading…
Reference in New Issue
Block a user