I am trying to add an image to the img-src="" attribute of b-carousel in BoostrapVue. The image is currently saved in the asset folder.
<b-carousel-slide img-src="../assets/life.jpg">
<h1>Hello world!</h1>
</b-carousel-slide>
I have added
Find below images of the result:
I am certain the images are correctly saved in the right location:
If using a loader with webpack (i.e. vue-loader, url-loader, etc), you need to ensure that the loader knows that img-src accepts a URL.
See the docs on information on how to tell the loaders to handle URL props on custom components: https://bootstrap-vue.js.org/docs/reference/images (specifically Vue Loader transformAssetUrls)
Related
Can you please help me with how we can load dynamically fonts in react native ClI. We have a theme drop down. Based on user selection will fetch the font file from s3 bucket url. But i didn't find a way to load fonts dynamically.
I have seen font-face css interface but we can use only for web app. Please find the below link.
https://developer.mozilla.org/en-US/docs/Web/API/FontFace
react-native-dynamic-font package was there but having issues with iOS. https://www.npmjs.com/package/react-native-dynamic-font
Can any one help me how we can load font dynamically
I'm using next-image, all my images are on cloudinary, and the image showing ✅. However, when I analyse my website with Screaming Frog or other SEO tools, I get a ton of 404s, since they look for those images on my domain.
For example:
next-image component
<Image
src={`/blog/${imageSlug}`} <=== relative path to image
width="800"
height="800"
/>
Next.js takes the relative path and combines it with the images path in the next.config file. So we get: https://res.cloudinary.com/jumbodonuts/image/upload/blog/donut.jpg
next.config
images: {
loader: 'cloudinary',
path: 'https://res.cloudinary.com/jumbodonuts/image/upload/',
domains: ['res.cloudinary.com']
}
My images are all showing, so it does work. However, the SEO tools / Google seem to think I have my images on the domain my website is on. They think the relative path is a relative path on my own domain: e.g. : www.jumbodonuts.com/blog/donut.jpg - this results then in a 404 and is bad for my SEO. One thing to note here is that I am using nextjs static site generation feature (next export), not sure if this makes a difference.
What can I do here? Am I not using next-image correctly?
You need to configure the loader.
Read more about: https://nextjs.org/docs/basic-features/image-optimization#loader
The next/image component's default loader is not supported when using next export. However, other loader options will work.
I am using React for a project and I'm trying to set a desired image to be the first image a root component loads, right now the first image being loaded is the logo from navbar component that's also a part of the root page component.
I've looked online for a solution but didn't find any, is there any way to do that in React? something like delaying the rendering of all other images except one.
The reason that I want to achieve this is to share the production webpage in an app, and the app takes the first image loaded as the default cover image for the shared link.
Apps generally use images declared in a meta tag as the preview. You should check which meta tag the other site uses, grabbing the "first" image is likely just a fallback for a missing meta tag
const {complete} = document.getElementById("myImg") // select image. You can use ref here as well.
if (complete) {/*do your stuff, eg setState({displayContent: true})*/}
There are many questions asking how to change the theme in Semantic-UI, but I have not been able to find even a question where it refers to changing the theme dynamically, i.e. after a webpack build.
I want to allow each user of a site to save their own preference for the theme. I have some users who prefer dark themes, and others who are color-blind, and others who have weak eyes and need larger fonts, or more contrast, etc.
I know it's possible to change the theme dynamically since the semantic-ui demos all do it. Unfortunately, the Theming page and all documentation I have seen describes how to change the site-wide theme, and apply that, in a new site-wide build. Or to customize that (still) site-wide build.
I think I'd be happy to just be able to add a class to the class list for an element (e.g. "github") and have it use that theme for that user (even if it was just for that element). But ideally, I'd like to have my page load an extra .less or .css file(s) with site-wide overrides for that user, for the user-selected theme.
I'm still pretty new semantic-ui and to applying dynamic changes to a webpack site. Any suggestions for how to apply additional less variable changes after build, or to reload entire Semantic-UI themes, like the demo does?
Note that demo site is not a link to GitHub; it's a look-alike with a paint can icon near the top-right which brings up a sidebar that allows you to change themes. Dynamically.
Update:
I need to test this now, but I may have an answer for my own question here.
It seems that the gulp build process typically compiles and combines all the less and other files into the dist folder as semantic.css, semantic.js, semantic.min.css and semantic.min.js. It also produces different individual component .css files in the dist/components subfolder, but (I think) if you're loading the full css file (e.g. semantic.min.css), that you don't really need the components subfolder. That this is present for those sites who want to optimize to the point of only including the .css files for the components they use?
So it's already processed and combined, and to swap themes, I think all that is necessary is to swap one semantic.min.css file with the output of the build for another theme. The .js files are the same, at least for default vs github themes.
If this is true, it's a matter of copying the semantic.min.css to an alternative file, for example, semantic.github.min.css and use that .css file instead. Or copy it to a theme subfolder like github/semantic.min.css. Then, in either case, update the DOM with a new href on the stylesheet originally referenced.
Summary: It looks like it's all in the semantic*.css file and swapping the output of different builds allows us to swap themes. I'll test this later tonight.
Update 2:
I updated the theme.config file with all github entries, then rebuilt the dist folder, copied the semantic.min.css as semantic-github.min.css to my static folder with the original, then just updated the href to select it:
// normally: <link rel="stylesheet" type="text/css" href="/static/semantic/semantic.min.css">
// non-default: <link rel="stylesheet" type="text/css" href="/static/semantic/semantic-theme.min.css">
function swapThemeCss (theme) {
console.log('Theme change to "' + theme + '".')
let sheet = document.querySelector('#theme')
if (!sheet) {
return
}
if (theme === 'default') {
sheet.setAttribute('href', '/static/semantic/semantic.min.css')
} else {
sheet.setAttribute('href', '/static/semantic/semantic-' + theme + '.min.css')
}
}
Oh also, in the example above, I gave the link an id of 'theme' to make it easier to find it and replace the href dynamically:
<link id="theme" rel="stylesheet" type="text/css" href="/static/semantic/semantic.min.css">
"So it's already processed and combined, and to swap themes, I think all that is necessary is to swap one semantic.min.css file with the output of the build for another theme."
Correct.
Depending on whether you're having per-user styles, or just multiple themes the user can pick from, you can simply have separate less files with per-theme overrides that can be compiled with webpack but perhaps not inserted into your index.html. Then you can dynamically add/remove the <link>s to depending on the user preference. The dynamic adding will cause a flicker from the default styles to the per-user theme styles if you're inserting the <link> tags via frontend javascript (because it must wait for the frontend JS to load, which will render the page/default styles in the meantime, then inject the new <link> and only show the new styles once those have been loaded). Add the per-user <link> tags serverside to make it seamless.
I need to add a CSHTML/HtML both type of pages as the part of the theme only (i.e. inside the theme folder) They are added in the folder but we can use only one page of the theme i.e. Layout.cshtml as master page. The other I need to add are test pages but I need to use that as to put some content & display. How to display them?
http://localhost:65012/Themes/MyTheme/demos/layout1.html
This gives 'The resource cannot be found' Error.
any suggestions
To be able to download static files you need a to enable the StaticFileModule of II7, or the StaticFileHandler for II6.
The fastest way to do so is copy the web.config file from a folder like Media to your demos folder.