What is the right way to access images in Jhipster - jhipster

I have some images under src/main/webapp/dist/img
I am able to access these files from my html templates, using relative paths:
<img src="../../../dist/img/user2-160x160.jpg" class="user-image" alt="User Image">
If I move the file to a subfolder, I have to update all paths.
What is the correct way to access images in a JHipster generated application?

Put it into the content folder and you can reference like this:
<img src="/content/avatar.png" />

Related

Static File On Django 3.2 Not Loading

My Problem is quite simple and yet I'm finding it so hard to solve it.
The problem is I am not able to load the CSS File and image which are on the static folder located on the root folder of the project. The static folder is not under the app name.
My project name is "ecommerce" and my app name is "store".
This is my file hierarchy for my project.
This is my settings.py
I have added my app too.
Yes, the STATICFILES_DIRS too.
Tried the other one too.
STATICFILES_DIRS = [
BASE_DIR / "static",
]
I used temp.html for showing the demo and here is my code.
And the CSS file which is named main.css
After doing all the things properly, the CSS file and image won't load.
Errors That I got in my terminal
And in developer mode in Chrome
As I know this is quite a rookie mistake and I am a beginner. I can't continue forward till this problem is solved. I'd be grateful if someone could come forward and assist me in resolving the issue.
First of all move your static folder in app directory that is store here
Now make another store folder inside the static
static/store
Now make all folders like css, js and img in static/store directory. Then Replace your css link in this link
<link rel="stylesheet" href="{% static 'css/main.css' %}">
And img tag link.
<img src="{% static 'images/cart.png' %}" alt="My image">

Unable to load GLTF file in ASP.NET View implementing A-FRAME

One of the views (.cshtml file) of my ASP.NET MVC application is using A-Frame. I am trying to load a 3-D model using GLTF file inside the <a-scene> tag.
<body>
<a-scene>
<a-assets timeout="5000">
<a-asset-item id="tree" src="~/Assets/scene.gltf">
</a-assets>
<a-gltf-model src="#tree"></a-gltf-model>
</a-scene>
</body>
I have already tested the src path in the same page by putting a .png file and loading it in <img/>, it works. The problem is just with the .gltf file.
What is possibly wrong with the .gltf file in particular?
The URL doesn't seem like a valid URL. It seems like a Unix path. Host the GLTF somewhere the website can reach it (like the same directory) and fix the path. src="scene.gltf".

Orchard CMS render media public URL for path in theme razor template

Looking to add a theme setting for a site logo URL to render in the header. However, when using Azure blob storage for images, the URL is not relative and will need to ask the media library for the public URL.
Just wondering what the best way to do this is from the shape template for my header / branding?
Currently is only working with file system media storage:
<a class="logo" href="#Href("~/")">
<img width="103" height="39" alt="" src="#Href(settings.SiteLogoUrl)" >
</a>
Prefer to sore only a relative path in the setting so that any changes to public URL of the Auzre blob storage wont break the site.
Found a solution that works. In the view you can resolve the storage provider, and then use that to get the public URL
#{
var storageProvider = WorkContext.Resolve<IStorageProvider>();
}
<a class="logo" href="#Href("~/")">
<img width="103" height="39" alt="" src="#Href(storageProvider.GetPublicUrl(settings.SiteLogoUrl))" >
</a>

Kentico Media Library Relative URL

We have a Kentico project where we're using Azure Blob Storage for our media storage. When selecting a media file in a page, it stores the URL like this: www.ourhost.net/blobcontainer/kenticosite/media/medialibrary/picture.jpg
We are also using ImageProcessor.org. This only works when the image is requested through the host itself, so we need the media library selector to store the absolute URL like this: /blobcontainer/kenticosite/media/medialibrary/picture.jpg
How can this be done?
Thanks in advance. Nicolas.
I assume you are talking about Media selection form control, is that correct?
In this case the solution is for you to remove the protocol/domain from the absolute URL which is stored by the form control. You can do this by creating Custom macro since you are using Portal engine macros.
The purpose of the macro will simply be to take the absolute URL and make it a relative URL.
Instead of using this:
<img src="{% CurrentDocument["HeaderImage"] #%}" alt="{% CurrentDocument["Title"] #%}" />
You would call it like:
<img src="{% MyMacros.GetRelativeUrl(CurrentDocument["HeaderImage"]) #%}" alt="{% CurrentDocument["Title"] #%}" />
As you can see I'm using "MyMacros" namespace which is a best practise as it will enable you to keep all your macros organized. You can create custom namespaces as per this article

How to create Angularjs layout templates

I am creating a node.js web application where I am using Yeoman angular scaffolding for client side.
I have an index.html which has all the javascript files included to load.
What i want to do is have a header file that will contain users name using model binding. These need to be included in all pages.
How can i achieve this?
You need to use ng-include directive to include partials.
Your index page would be structure something like
<body>
<div id='header' ng-include='/partials/header'/>
<div ng-view />
</body>

Resources