Can't load variable image with spring boot thymeleaf - spring-boot

I'm very new to spring boot, and I have to do a proyect with Thymeleaf.
I can't figure out how to load the variable images from my folders.
<div class="row" th:fragment="searched-film">
<div class="card m-2" style="width: 12rem;" th:each="film : ${films}">
<img alt="Póster de la película" class="card-img-top p-3"
th:src="#{${'./static/images/peliculas/' + film.poster}}">
<div class="card-body">
<h5 class="card-title" th:text="${film.title}"></h5> <h6 class="card-title"
th:text="'(' + *{film.year} + ')'"></h6>
</div>
</div>
</div>
Title and the year works, but images dont load.
the files are in 'FilmoTokio\src\main\resources\static\images\peliculas', meanwhile this html in 'FilmoTokio\src\main\resources\templates'
This is the github: FilmoTokio
I tried to change the link, I used th:hrc, I changed the folder's name...

Related

How can I display vue.js data in blade

I am doing a small project with vue.js and laravel. I have a list of products, when I click on a specific product on "Quick view" button I want to show all data about that product in a modal but the data is not showing in the modal.
Can you help me please. Here is my code:
#extends('app')
#section('content')
<div id ="crud" class="row">
<div class="col-xs-12">
<h1 class="page-header">Lista de Articulo</h1>
</div>
<div class="wrap-icon right-section col-md-12" data-toggle="modal" data-target="#list" >
<div class="wrap-icon-section wishlist">
<a href="#" class="link-direction">
<i class="fa fa-heart" aria-hidden="true"></i>
<div class="left-info">
<span class="index">0 item</span>
<br>
<span class="title">Wishlist</span>
</div>
</a>
</div>
</div>
<div class="row">
<div v-for="keep in keeps" class="col-md-4" style="width:25%;" #mouseover="showByIndex = keep" #mouseout="showByIndex = null">
<div class="container">
<img :src="keep.foto" style="width:100%; max-width:150px;">
<button class="btn" v-show="showByIndex === keep" v-on:click.prevent="showKeep(keep)">Quick view</button>
</div>
<h3>
<b> #{{keep.nombre}}</b>
</h3>
<p> #{{keep.descripcion}}</p>
I fixed it. The error was because I called the modal file outside the div. Thanks to everybody.
you can't send data directly from vue in blade structure, you need to write a component for that.
https://v3.vuejs.org/examples/modal.html#modal-component

I can't upload images to my website. How can I fix?

When I get the picture from the url, I can put it on my site, but I cannot upload it from my pc.
Can you explain to me how Laravel uses src?
<div class="card bg-dark text-white">
<img src=" /img/manzara.jpg " class="card-img" alt="...">
<div class="card-img-overlay">
<h5 class="card-title">Card title</h5>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
<p class="card-text">Last updated 3 mins ago</p>
</div>
If the image is the public folder, change your tag as below:
<img src="{{asset('/img/manzara.jpg')}}" class="card-img" alt="...">

Can't seem to get Col-4 Working on Laravel

So I am trying to create a car sales website using Laravel. The code presented shows 20 Cars from the database being shown but all one after the other. I want it to appear in columns of 3 or 4 if possible. I've been trying to use col-4 but it doesn't make any difference. Any help appreciated. The only answer I could find online was that the container was within the row but I don't have this issue so unsure.
<div class="container text-center">
<h2>Cars</h2>
<div class="row">
#foreach ($allcars as $car)
<div class="col-4">
<div class="card">
<img class="card-img-top" src="{{asset('qashqai.jpg')}}" alt="Card
image cap">
<div class="card-body">
<h4 class="card-title">{{$car->name}}</h4>
<p class="card-text">{{$car->description}}</p>
</div>
<div class="card-body">
Card link
Another link
</div>
</div>
</div>
#endforeach
</div>
</div>

Spring : How to show image in thymeleaf from database

I'm doing project with Spring Boot+Spring Data+Spring MVC.I want to show image from database to thymeleaf but image not displayed. This is my code
<span th:each="room,iterStat : ${room}">
<div class="col-md-3 md-col">
<div class="col-md">
<a href="single.html" class="compare-in"><img th:src="#{/static/images/${room.image}}" alt="" />
</a>
<div class="top-content">
<h5><tr th:text="${room.name}"></h5>
<div class="white">
<a th:href="#{/room/{id}/book(id=${room.id})}" class="hvr-shutter-in-vertical hvr-shutter-in-vertical2">BOOK</a>
<p class="dollar"><span class="in-dollar">$</span><span>2</span><span>0</span></p>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</span>
I save image with name image in database and i save image in folder ../static/images .. When I copy images name in database instead of ${room.image} , image will display..I don't know why
I've got the same issue, I get the issue resolved by doing this :--
<th:style="'background-image:url('+ ${room.image}+');'"></div>
Hope it helps.

How to add images in codeigniter using Bootstrap

I have started designing a website using codeigniter tutorial from tuts plus and encountered problem on how to add carousel images using Bootstrap in codeigniter. My images are found at /images/...
How can I solve this problem?
<div class="intro-block">
<div class="container">
<div class="row">
<div class="span3">
<div class=" t">
</div>
</div>
<div class="span9">
<div id="artcoursel" class="carousel slide">
<div class="carousel-inner">
<img src= "images/test-1.png" alt="">
</div>
</div>
</div>
</div>
</div>
</div>
Try this.
<img src=<?php echo base_url('images/test-1.png')?>>

Resources