From 6fb20baf6afcbf58b115bfa48833c3ec96461eb2 Mon Sep 17 00:00:00 2001 From: Jerod Santo Date: Tue, 23 Jul 2024 13:04:34 -0500 Subject: [PATCH] Allow dynamic setting of width/height for news img --- .formatter.exs | 2 +- assets/app/img.css | 2 -- lib/changelog_web/controllers/episode_controller.ex | 7 ++++++- lib/changelog_web/templates/episode/img_news.html.heex | 7 ++++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.formatter.exs b/.formatter.exs index 8a6391c6a6..29b85518c1 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,5 +1,5 @@ [ import_deps: [:ecto, :phoenix], - inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"], + inputs: ["*.{heex,ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{heex,ex,exs}"], subdirectories: ["priv/*/migrations"] ] diff --git a/assets/app/img.css b/assets/app/img.css index 56dfee01c4..b8a96898f5 100644 --- a/assets/app/img.css +++ b/assets/app/img.css @@ -282,8 +282,6 @@ Changelog News background: var(--color-dark); margin: 0 auto 1rem; position: relative; - width: 1200px; - height: 630px; } .news-fade { diff --git a/lib/changelog_web/controllers/episode_controller.ex b/lib/changelog_web/controllers/episode_controller.ex index 9adfd9ee07..34bfb9bce5 100644 --- a/lib/changelog_web/controllers/episode_controller.ex +++ b/lib/changelog_web/controllers/episode_controller.ex @@ -27,14 +27,19 @@ defmodule ChangelogWeb.EpisodeController do |> render(:show) end - def img(conn, %{"slug" => slug}, podcast = %{slug: "news"}) do + def img(conn, params = %{"slug" => slug}, podcast = %{slug: "news"}) do episode = assoc(podcast, :episodes) |> Episode.preload_all() |> Repo.get_by!(slug: slug) + width = Map.get(params, "w", "1200") + height = Map.get(params, "h", "630") + conn |> assign(:episode, episode) + |> assign(:width, width) + |> assign(:height, height) |> render(:img_news, layout: false) end diff --git a/lib/changelog_web/templates/episode/img_news.html.heex b/lib/changelog_web/templates/episode/img_news.html.heex index 3ab0913bdd..5d42f176b2 100644 --- a/lib/changelog_web/templates/episode/img_news.html.heex +++ b/lib/changelog_web/templates/episode/img_news.html.heex @@ -6,6 +6,12 @@ <%= title_with_guest_focused_subtitle_and_podcast_aside(@episode) %> +
@@ -23,7 +29,6 @@ <% end %>
-