Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: filters/inline_image.py

Issue 4661048523096064: Issue 2120 - Add support for animations. (Closed)
Patch Set: Created April 9, 2015, 8:38 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | filters/localise_path.py » ('j') | static/js/animation.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filters/inline_image.py
diff --git a/filters/inline_image.py b/filters/inline_image.py
new file mode 100644
index 0000000000000000000000000000000000000000..fcdd8a4dfa846b49ab2955bf0fba1fc47ebd4aa4
--- /dev/null
+++ b/filters/inline_image.py
@@ -0,0 +1,23 @@
+# This file is part of the Adblock Plus website,
+# Copyright (C) 2006-2015 Eyeo GmbH
+#
+# Adblock Plus is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3 as
+# published by the Free Software Foundation.
+#
+# Adblock Plus is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+
+import mimetypes
+import urllib
+
+def inline_image(path):
+ mime_type = mimetypes.guess_type(path)[0]
+ with open(path, "rb") as f:
+ encoded = urllib.quote(f.read().encode("base64"))
+ return "data:%s;base64,%s" % (mime_type, encoded)
« no previous file with comments | « no previous file | filters/localise_path.py » ('j') | static/js/animation.js » ('J')

Powered by Google App Engine
This is Rietveld