Skip to content

Commit

Permalink
Add WebP mimetype at startup, not in gallery RSS
Browse files Browse the repository at this point in the history
Doing it early like this makes the added WebP mimetype available
to the several other places we call things like 'mimetypes.guess_type'.
  • Loading branch information
tartley committed Mar 27, 2023
1 parent cfa3441 commit c98b387
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 4 additions & 0 deletions nikola/nikola.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ def __init__(self, **config):
utils.LOGGER.warning('You are currently disabling "{}", but not the following new taxonomy plugins: {}'.format(old_plugin_name, ', '.join(missing_plugins)))
utils.LOGGER.warning('Please also disable these new plugins or remove "{}" from the DISABLED_PLUGINS list.'.format(old_plugin_name))
self.config['DISABLED_PLUGINS'].extend(missing_plugins)

# Special-case logic for "render_indexes" to fix #2591
if 'render_indexes' in self.config['DISABLED_PLUGINS']:
if 'generate_rss' in self.config['DISABLED_PLUGINS'] or self.config['GENERATE_RSS'] is False:
Expand Down Expand Up @@ -1000,6 +1001,9 @@ def __init__(self, **config):
self.state._set_site(self)
self.cache._set_site(self)

# WebP files have no official MIME type yet, but we need to recognize them (Issue #3671)
mimetypes.add_type('image/webp', '.webp')

def _filter_duplicate_plugins(self, plugin_list):
"""Find repeated plugins and discard the less local copy."""
def plugin_position_in_places(plugin):
Expand Down
3 changes: 0 additions & 3 deletions nikola/plugins/task/galleries.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,6 @@ def gallery_rss(self, img_list, dest_img_list, img_titles, lang, permalink, outp
def make_url(url):
return urljoin(self.site.config['BASE_URL'], url.lstrip('/'))

# WebP is not yet an official MIME type but we need to recognize them
mimetypes.add_type('image/webp', '.webp')

all_data = list(zip(img_list, dest_img_list, img_titles))

if self.kw['sort_by_date']:
Expand Down

0 comments on commit c98b387

Please sign in to comment.