Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions javascripts/discourse/components/modal/gif.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,22 @@ export default class Gif extends Component {
let images;

if (settings.api_provider === "giphy") {
// Giphy
images = data.data.map((gif) => ({
title: gif.title,
preview:
settings.giphy_file_format === "webp"
? gif.images.fixed_width.webp
: gif.images.fixed_width.url,
original:
settings.giphy_file_format === "webp"
? gif.images.original.webp
: gif.images.original.url,
width: gif.images.original.width,
height: gif.images.original.height,
}));
images = data.data.map((gif) => {
const sizeVariant = gif.images[settings.giphy_size_variant];
const isWebp = settings.giphy_file_format === "webp";

return {
title: gif.title,
preview:
settings.giphy_file_format === "webp"
? gif.images.fixed_width.webp
: gif.images.fixed_width.url,
original:
isWebp && sizeVariant.webp ? sizeVariant.webp : sizeVariant.url,
width: parseInt(sizeVariant.width, 10),
height: parseInt(sizeVariant.height, 10),
};
});
} else {
// Tenor
images = data.results.map((gif) => {
Expand Down
27 changes: 22 additions & 5 deletions settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ giphy_file_format:
choices:
- webp
- gif
giphy_size_variant:
type: enum
default: downsized_medium
description:
en: >
GIPHY: Size variant to use. Choose based on your site's upload limit.
<ul>
<li>downsized = Under 2MB</li>
<li>downsized_medium = Under 5MB (recommended for most sites)</li>
<li>downsized_large = Under 8MB</li>
<li>original = Full size with no limit</li>
<ul>
choices:
- original
- downsized_large
- downsized_medium
- downsized
giphy_content_rating:
type: enum
default: r
Expand Down Expand Up @@ -100,15 +117,15 @@ tenor_client_key:
en: "Tenor: (optional) client-specified string that represents the integration"
tenor_file_detail:
type: enum
default: gif
default: mediumgif
description:
en: >
Tenor: Image format to use
<ul>
<li>gif = High-quality GIF format</li>
<li>mediumgif = same height/width with small size reduction</li>
<li>tinygif = up to 220px wide</li>
<li>nanogif = up to 90 pixels tall</li>
<li>gif = Full size, highest quality (largest files)</li>
<li>mediumgif = Full size with compression to reduce file size (recommended for most sites)</li>
<li>tinygif = Scaled down to 220px wide (smaller files)</li>
<li>nanogif = Scaled down to 90px tall (smallest files)</li>
<ul>
choices:
- gif
Expand Down
Loading