Google Chrome Extensions - Can't load local images with CSS
Your image URL should look like chrome-extension://<EXTENSION_ID>/image.jpg
You would be better off replacing css through javascript. From docs:
//Code for displaying <extensionDir>/images/myimage.png:
var imgURL = chrome.extension.getURL("images/myimage.png");
document.getElementById("someImage").src = imgURL;
Cannot open local file - Chrome: Not allowed to load local resource
We use Chrome a lot in the classroom and it is a must to working with local files.
What we have been using is "Web Server for Chrome". You start it up, choose the folder wishing to work with and go to URL (like 127.0.0.1:port you chose)
It is a simple server and cannot use PHP but for simple work, might be your solution:
https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb
Test Local Background Image on Live Site with Chrome Dev Tools?
You can replace the url of the background image in the Elements
panel with the url of the image you wish to try. Check this link to see how that is done.
This change will show effect immediately in your browser window. As Johan Linder mentioned, you will have to host the image somewhere in case you have the image on your computer.
nate wilton's answer correctly points out how to do this using a Chrome extension.
Why i am getting chrome-extension://invalid/ error when trying to load local font
We can use chrome.runtime.getURL API to get the URL of our resource and then we can provide that URL in src of font-face.
const url = chrome.runtime.getURL('assets/ClashGrotesk-Variable.ttf')
const GlobalStyle = createGlobalStyle`
@font-face {
font-family: 'ClashGrotesk-Variable';
src: url(${url});
font-weight: 200 700;
font-display: swap;
font-style: normal;
}
html body {
font-family: 'ClashGrotesk-Variable';
}
`
References
- Google Chrome extension relative path
- https://developer.chrome.com/docs/extensions/reference/runtime/#method-getURL
Related Topics
How to Make Child Element Higher Z-Index Than Parent
How to Use Svg as Content in a Pseudo Element ::Before or ::After
Media Query to Detect If Device Is Touchscreen
How to Set Border'S Thickness in Percentages
What Is the Purpose of the '@' Symbol in Css
:Not() Selector Not Behaving the Same Between Safari and Chrome/Firefox
Css Text-Decoration Property Cannot Be Overridden by Child Element
How to Use Particular CSS Styles Based on Screen Size/Device
Drop Shadow For Png Image in Css
How to Insert a Line Break Before an Element Using Css
How to Automatically Crop and Center an Image
Css Transparent Curved Shape With Two Rounded Sides
Css Background Opacity With Rgba Not Working in Ie 8
What Does an Asterisk Do in a CSS Property Name
How to Scale an Image in a CSS Sprite
Why Is @Font-Face Throwing a 404 Error on Woff Files