DEV: Allow plugins to request topic thumbnail sizes (#9828)

In plugin.rb, you can register new sizes like

```
register_topic_thumbnail_size [512, 512]
```

For more information about thumbnails see 03818e642a
This commit is contained in:
David Taylor
2020-05-19 10:38:58 +01:00
committed by GitHub
parent f2574736a2
commit 725e38f9d7
4 changed files with 49 additions and 4 deletions

View File

@@ -165,6 +165,16 @@ class Plugin::Instance
DiscoursePluginRegistry.register_editable_group_custom_field(field, self)
end
# Request a new size for topic thumbnails
# Will respect plugin enabled setting is enabled
# Size should be an array with two elements [max_width, max_height]
def register_topic_thumbnail_size(size)
if !(size.kind_of?(Array) && size.length == 2)
raise ArgumentError.new("Topic thumbnail dimension is not valid")
end
DiscoursePluginRegistry.register_topic_thumbnail_size(size, self)
end
def custom_avatar_column(column)
reloadable_patch do |plugin|
AvatarLookup.lookup_columns << column