diff --git a/lib/philomena/users/user.ex b/lib/philomena/users/user.ex index aed48341..3092153f 100644 --- a/lib/philomena/users/user.ex +++ b/lib/philomena/users/user.ex @@ -79,7 +79,7 @@ defmodule Philomena.Users.User do field :fancy_tag_field_in_settings, :boolean, default: true field :autorefresh_by_default, :boolean, default: false field :anonymous_by_default, :boolean, default: false - field :scale_large_images, :boolean, default: true + field :scale_large_images, :string, default: "true" field :comments_newest_first, :boolean, default: true field :comments_always_jump_to_last, :boolean, default: true field :comments_per_page, :integer, default: 20 @@ -347,6 +347,7 @@ defmodule Philomena.Users.User do |> validate_inclusion(:theme, ~W(default dark red)) |> validate_inclusion(:images_per_page, 1..50) |> validate_inclusion(:comments_per_page, 1..100) + |> validate_inclusion(:scale_large_images, ["false", "partscaled", "true"]) |> Search.validate_search(:watched_images_query_str, user, true) |> Search.validate_search(:watched_images_exclude_str, user, true) end diff --git a/lib/philomena_web/templates/setting/edit.html.slime b/lib/philomena_web/templates/setting/edit.html.slime index 59843d3a..a795d616 100644 --- a/lib/philomena_web/templates/setting/edit.html.slime +++ b/lib/philomena_web/templates/setting/edit.html.slime @@ -73,15 +73,15 @@ h1 Content Settings i ' This is the number of images per page that are displayed on image listings and searches, up to a maximum of 50. ' For 1080p monitors, try 24. - .field - => label f, :scale_large_images - => checkbox f, :scale_large_images, class: "checkbox" - .fieldlabel: i Scale large images down to fit your monitor (approximately) server-side before downloading. Disabling this will load full images immediately on image pages. .field => label f, :theme => select f, :theme, theme_options(@conn), class: "input" = error_tag f, :theme .fieldlabel: i Preview themes by selecting one from the dropdown. Saving sets the currently selected theme. + .field + => label f, :scale_large_images + => select f, :scale_large_images, scale_options(), class: "input" + = error_tag f, :scale_large_images .block__tab.hidden.flex.flex--maybe-wrap data-tab="comments" div diff --git a/lib/philomena_web/views/image_view.ex b/lib/philomena_web/views/image_view.ex index c63977d9..b0e48666 100644 --- a/lib/philomena_web/views/image_view.ex +++ b/lib/philomena_web/views/image_view.ex @@ -203,7 +203,7 @@ defmodule PhilomenaWeb.ImageView do def deleter(%{deleter: %{name: name}}), do: name def deleter(_image), do: "System" - def scaled_value(%{scale_large_images: false}), do: "false" + def scaled_value(%{scale_large_images: scale}), do: scale def scaled_value(_user), do: "true" def hides_images?(conn), do: can?(conn, :hide, %Philomena.Images.Image{}) diff --git a/lib/philomena_web/views/setting_view.ex b/lib/philomena_web/views/setting_view.ex index f570b1bd..df313385 100644 --- a/lib/philomena_web/views/setting_view.ex +++ b/lib/philomena_web/views/setting_view.ex @@ -13,6 +13,14 @@ defmodule PhilomenaWeb.SettingView do ] end + def scale_options do + [ + [key: "Load full images on image pages", value: "false"], + [key: "Load full images on image pages, sized to fit the page", value: "partscaled"], + [key: "Scale large images down before downloading", value: "true"] + ] + end + def local_tab_class(conn) do case conn.assigns.current_user do nil -> "" diff --git a/priv/repo/migrations/20210921025336_change_image_scale_option_type.exs b/priv/repo/migrations/20210921025336_change_image_scale_option_type.exs new file mode 100755 index 00000000..d153c670 --- /dev/null +++ b/priv/repo/migrations/20210921025336_change_image_scale_option_type.exs @@ -0,0 +1,17 @@ +defmodule Philomena.Repo.Migrations.ChangeImageScaleOptionType do + use Ecto.Migration + + def change do + alter table(:users) do + add :scale_large_images0, :string, default: "true", null: false + end + + execute("update users set scale_large_images0 = (case when scale_large_images then 'true' else 'false' end);") + + alter table(:users) do + remove :scale_large_images + end + + rename table(:users), :scale_large_images0, to: :scale_large_images + end +end diff --git a/priv/repo/structure.sql b/priv/repo/structure.sql index 37f4c2c0..a691f993 100644 --- a/priv/repo/structure.sql +++ b/priv/repo/structure.sql @@ -1964,7 +1964,6 @@ CREATE TABLE public.users ( fancy_tag_field_in_settings boolean DEFAULT true NOT NULL, autorefresh_by_default boolean DEFAULT false NOT NULL, anonymous_by_default boolean DEFAULT false NOT NULL, - scale_large_images boolean DEFAULT true NOT NULL, comments_newest_first boolean DEFAULT true NOT NULL, comments_always_jump_to_last boolean DEFAULT false NOT NULL, comments_per_page integer DEFAULT 20 NOT NULL, @@ -2010,9 +2009,10 @@ CREATE TABLE public.users ( forced_filter_id bigint, confirmed_at timestamp(0) without time zone, senior_staff boolean DEFAULT false, - bypass_rate_limits boolean DEFAULT false, description_md character varying, - scratchpad_md character varying + scratchpad_md character varying, + bypass_rate_limits boolean DEFAULT false, + scale_large_images character varying(255) DEFAULT 'true'::character varying NOT NULL ); @@ -4870,3 +4870,4 @@ INSERT INTO public."schema_migrations" (version) VALUES (20210301012137); INSERT INTO public."schema_migrations" (version) VALUES (20210427022351); INSERT INTO public."schema_migrations" (version) VALUES (20210912171343); INSERT INTO public."schema_migrations" (version) VALUES (20210917190346); +INSERT INTO public."schema_migrations" (version) VALUES (20210921025336);