Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gajim-plugins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gajim
gajim-plugins
Commits
08cd37b8
Commit
08cd37b8
authored
5 years ago
by
Comrade DOS
Committed by
Philipp Hörist
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[preview] Adding detection of supported mime types at runtime
parent
834d3713
No related branches found
Branches containing commit
No related tags found
1 merge request
!184
Adding detection of supported mime types at runtime
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
url_image_preview/url_image_preview.py
+17
-8
17 additions, 8 deletions
url_image_preview/url_image_preview.py
with
17 additions
and
8 deletions
url_image_preview/url_image_preview.py
+
17
−
8
View file @
08cd37b8
...
...
@@ -26,6 +26,7 @@ from gi.repository import Gtk
from
gi.repository
import
Gdk
from
gi.repository
import
GLib
from
gi.repository
import
Soup
from
gi.repository
import
GdkPixbuf
from
gajim.common
import
app
from
gajim.common
import
configpaths
...
...
@@ -52,6 +53,7 @@ ERROR_MSG = None
try
:
from
PIL
import
Image
# pylint: disable=unused-import
except
ImportError
:
Image
=
None
log
.
error
(
'
Pillow not available
'
)
ERROR_MSG
=
_
(
'
Please install python-pillow
'
)
...
...
@@ -73,14 +75,21 @@ if ERROR_MSG is None:
from
url_image_preview.utils
import
filename_from_uri
# pylint: enable=ungrouped-imports
ACCEPTED_MIME_TYPES
=
[
'
image/png
'
,
'
image/jpeg
'
,
'
image/gif
'
,
'
image/raw
'
,
'
image/svg+xml
'
,
'
image/x-ms-bmp
'
,
]
def
get_accepted_mime_types
():
accepted_mime_types
=
set
()
for
fmt
in
GdkPixbuf
.
Pixbuf
.
get_formats
():
for
mime_type
in
fmt
.
get_mime_types
():
accepted_mime_types
.
add
(
mime_type
.
lower
())
if
Image
is
not
None
:
Image
.
init
()
for
mime_type
in
Image
.
MIME
.
values
():
accepted_mime_types
.
add
(
mime_type
.
lower
())
return
tuple
(
filter
(
lambda
mime_type
:
mime_type
.
startswith
(
'
image
'
),
accepted_mime_types
))
ACCEPTED_MIME_TYPES
=
get_accepted_mime_types
()
class
UrlImagePreviewPlugin
(
GajimPlugin
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment