berrypod/lib/berrypod/media/favicon_variant.ex
jamey f788108665
All checks were successful
deploy / deploy (push) Successful in 1m26s
add favicon and site icon generation from uploaded images
Upload a source image (PNG, JPEG, or SVG) and get a complete favicon
setup: PNG variants at 32, 180, 192, 512px served from DB via
FaviconController with ETag caching, SVG favicon for vector sources,
dynamic site.webmanifest, and theme-color meta tag. Theme editor gains
a site icon section with "use logo as icon" toggle, dedicated icon
upload, short name, and background colour picker.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 17:22:15 +00:00

27 lines
688 B
Elixir

defmodule Berrypod.Media.FaviconVariant do
use Ecto.Schema
import Ecto.Changeset
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "favicon_variants" do
field :source_image_id, :binary_id
field :png_32, :binary
field :png_180, :binary
field :png_192, :binary
field :png_512, :binary
field :svg, :string
field :generated_at, :utc_datetime
timestamps(type: :utc_datetime)
end
@doc false
def changeset(variant, attrs) do
variant
|> cast(attrs, [:source_image_id, :png_32, :png_180, :png_192, :png_512, :svg, :generated_at])
|> validate_required([:source_image_id, :generated_at])
end
end