Skip to content

Instantly share code, notes, and snippets.

View jgb-solutions's full-sized avatar
on to something

Jean Bousiquot jgb-solutions

on to something
View GitHub Profile
@jgb-solutions
jgb-solutions / Image.ex
Created September 30, 2022 23:19
Photon Image service module in Elixir
defmodule JGBSolutions.Image do
# https://developer.wordpress.com/docs/photon/api/
@photon_hosts ["i0.wp.com", "i1.wp.com", "i2.wp.com", "i3.wp.com"]
def get_photon_url(url, opts \\ []) do
url = Application.get_env(:jgb_solutions, :domain) <> url
if String.starts_with?(url, "http") do
url_without_protocol = make_url_without_protocol(url)
@jgb-solutions
jgb-solutions / Image.ex
Created June 19, 2024 01:34
Image CDN module to transform any remote image and serves it from a CDN
```ex
defmodule JGBSolutions.Image do
# https://developer.wordpress.com/docs/photon/api/
@photon_hosts ["i0.wp.com", "i1.wp.com", "i2.wp.com", "i3.wp.com"]
def get_photon_url(url, opts \\ []) do
url = Application.get_env(:jgb_solutions, :domain) <> url
if String.starts_with?(url, "http") do