| 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) |