I am trying to display image which is inside my webapp/WEB-INF/images folder. And I am using
<c:url value="/images/${product.productId}.png" />
To get the image in JSP. But it is not working. Please help me out with this.
Related
I'm trying to load an image from my project's local storage in email with Thymeleaf but it won't !
<img src="../static/img/logo.png" alt="MyPicture" th:src="#{img/logo.png}">
although when I try with an absolute path it's perfectly loading
<img src="C:/Workspace/myProject/src/main/resources/static/img/logo.png" alt="MyPicture">
My images are stored in static/img
The image path shall start with a forward slash like
<img alt="MyPicture" th:src="#{/img/logo.png}">
try changing your path to
<img src="img/logo.png" alt="MyPicture">
and you might also want to invalidate cache from your IDE settings for the image to be detected
I am trying to create a blogging application with Laravel and so I got this in my view
<img src="{{$post->image}}" />
the image is not showing up but the post title shows up.
I tried:
php artisan storage:link
and its return:
The "public/storage" directory already exists.
but yet still no image displays
Based on your comment, you upload the image to a private storage folder so it's will never show. You should upload to the public folder using code like this:
$image = $request->image->store('posts','public');
then if you want to show it just use <img src="{{url("storage/".$post->image)}}" />
I have successfully deployed my laravel project to shared hosting (cPanel) and all seems to be working apart from the images. The images stored directly on the server e.g. logo.png don't show up and yet css files in the same public directory show up.
When I try to view the image directly via its URL, I still can't access it and gives me an error of "The image "http://..." cannot be displayed because it contains errors.
Could you please advise? Thanks in advance
Updated:
I have tried several alternatives which work locally but not when I upload.
< img src="/img/logo.png" width="100" />
< img src="{{ asset('/img/logo.png') }}" width="100" />
None of the above works and even when I try to access it via http://sub.domain.com/img/logo.png . It gives the error above
It turns out that the problem wasn't with the RewriteRule but rather the ftp client uploading the images with ASCII format. Laravel doesn't seem to pick those images so I re-ftped them with binary format and everything is working fine.
I hope this can help someone else.
my folder structure
enter image description here
And my code in the JSP page is
<script src='${pageContext.request.contextPath}/AppNameController.js'/>
I'm still getting 404 error
You have the prefix set to /WEB-INF/jsp but looking at your project structure your index.jsp is only within the /WEB-INF folder rather than inside the /WEB-INF/jsp folder.
Also change to:
${pageContext.request.contextPath}/resources/scripts/AppNameController.js
I'm using spring tiles framework to display the screens where I have mentioned spring url for image path by giving like ${baseurl}.
It is working fine in both Mozilla and safari browsers desktop.when I try to access the application by ipad browser(safari)there i'm not able to see my image getting loaded.
Please help me on this.
I highly doubt that the browser affect the way tiles work.
I can imagine that the way you referere to an image url in you jsp is wrong. The recomended way is somethink like that:
<c:url value="/imagefolder/myimage.png" var="imgUrl" />
<img src="${imgUrl}" width="64" height="64" />