data-uri

Content-Security-Policy (CSP): how to allow svg image in object

情到浓时终转凉″ 提交于 2021-02-08 13:07:25
问题 I am using the js plugin that adds inside itself SVG images. I have added CSP policy to my website, but I can't configure it to allow plugin's code. Its code looks like: label=$("<object style='height:10px; width:10px;' type='image/svg+xml' data='data:image/svg+xml;charset=UTF-8," + "<svg xmlns=\"http://www.w3.org/2000/svg\">" + "<rect x=\"0\" y=\"0\" some parameters/>"+ "<text>SomeText</text></svg>'></object>"); el.html(label) I am looking for a configuration that allows SVG image that is

Python requests base64 image

旧街凉风 提交于 2021-02-08 12:21:14
问题 I am using requests to get the image from remote URL. Since the images will always be 16x16, I want to convert them to base64 , so that I can embed them later to use in HTML img tag. import requests import base64 response = requests.get(url).content print(response) b = base64.b64encode(response) src = "data:image/png;base64," + b The output for response is: response = b'GIF89a\x80\x00\x80\x00\xc4\x1f\x00\xff\xff\xff\x00\x00\x00\xff\x00\x00\xff\x88\x88"""\xffff\... The HTML part is: <img src="

Can you use CSS selectors on SVG rendered via CSS Data URI?

好久不见. 提交于 2021-01-28 07:54:48
问题 I have some inline SVG with class names for styling via CSS selectors. I would like to bring the SVG into my CSS as a background-image data URI, but does this mean I can't use the CSS selectors anymore? I've read the existing StackOverflow responses, and the takeaway seems to be "You can't apply CSS because it's an image or resource from potentially another site". How do I change the colour of an SVG image in a CSS content property? Modify SVG fill color when being served as Background-Image

How to inline fonts in CSS with webpack?

﹥>﹥吖頭↗ 提交于 2021-01-26 21:30:40
问题 Problem background: I am using katex to render some math on a page. I then want to create a PDF version of part of that page, so I create a HTML document that containing the part to be exported that inlines all CSS and pass it to the renderer. The renderer cannot access the node resources, that's why everything is inlined. It works perfectly, except for the fonts. I tried both url-loader and bas64-inline-loader, but the generated fonts are not inlined. I inspected the generated CSS in the

LESS — data-uri painter mixin

一笑奈何 提交于 2020-04-10 05:50:52
问题 I’m trying to implement mixin customizing underline of text, like polyfill for CSS3 text-decoration properties: line, style, color, which are not supported yet by browsers. My idea is to perform painting proper line in canvas, then convert it to data-uri and use it as background for target element. Problem is when compiling LESS with node.js, there is no canvas in environment. Technically I could use node-canvas to perform this task, but I don’t want to make any dependencies for node just to

LESS — data-uri painter mixin

霸气de小男生 提交于 2020-04-10 05:49:26
问题 I’m trying to implement mixin customizing underline of text, like polyfill for CSS3 text-decoration properties: line, style, color, which are not supported yet by browsers. My idea is to perform painting proper line in canvas, then convert it to data-uri and use it as background for target element. Problem is when compiling LESS with node.js, there is no canvas in environment. Technically I could use node-canvas to perform this task, but I don’t want to make any dependencies for node just to

Img url to dataurl using JavaScript

你离开我真会死。 提交于 2020-03-18 12:12:08
问题 Using JavaScript, I want to convert an img tag like this: <img width="11" height="14" src="http://mysite/file.gif" alt="File Icon"> Into one with a dataurl like this: <img width="11" height="14" src="data:image/gif;base64,R0lGODlhCwAOAMQfAP////7+/vj4+Hh4eHd3d/v7+/Dw8HV1dfLy8ubm5vX19e3t7fr6+nl5edra2nZ2dnx8fMHBwYODg/b29np6eujo6JGRkeHh4eTk5LCwsN3d3dfX13Jycp2dnevr6////yH5BAEAAB8ALAAAAAALAA4AAAVq4NFw1DNAX/o9imAsBtKpxKRd1

Img url to dataurl using JavaScript

喜夏-厌秋 提交于 2020-03-18 12:11:33
问题 Using JavaScript, I want to convert an img tag like this: <img width="11" height="14" src="http://mysite/file.gif" alt="File Icon"> Into one with a dataurl like this: <img width="11" height="14" src="data:image/gif;base64,R0lGODlhCwAOAMQfAP////7+/vj4+Hh4eHd3d/v7+/Dw8HV1dfLy8ubm5vX19e3t7fr6+nl5edra2nZ2dnx8fMHBwYODg/b29np6eujo6JGRkeHh4eTk5LCwsN3d3dfX13Jycp2dnevr6////yH5BAEAAB8ALAAAAAALAA4AAAVq4NFw1DNAX/o9imAsBtKpxKRd1

How to detect Microsoft Chromium Edge (chredge , edgium) in Javascript

旧时模样 提交于 2020-02-28 08:25:53
问题 'Edge 75' will be (is?) the first Chromium Based Edge browser. How can I check if this browser is Edge on Chrome ? (What I really want to know is if the browser fully supports data-uri's - https://caniuse.com/#feat=datauri - so feature detection would even be better. If you know a way to do that, I can change the question) 回答1: You could use the window.navigator userAgent to check whether the browser is Microsoft Chromium Edge or Chrome. Code as below: <script> var browser = (function (agent)