Images not cropping
This commit is contained in:
parent
c021498808
commit
18de453ac1
3 changed files with 14 additions and 12 deletions
7
app.js
7
app.js
|
|
@ -189,6 +189,7 @@ function renderRoutes() {
|
|||
function createRouteCard(route) {
|
||||
const card = template.content.firstElementChild.cloneNode(true);
|
||||
const image = card.querySelector(".route-image");
|
||||
const picture = card.querySelector(".route-picture");
|
||||
const meta = card.querySelector(".route-meta");
|
||||
const title = card.querySelector(".route-title");
|
||||
const description = card.querySelector(".route-description");
|
||||
|
|
@ -205,7 +206,7 @@ function createRouteCard(route) {
|
|||
|
||||
if (route.picture) {
|
||||
image.hidden = false;
|
||||
image.style.backgroundImage = `url("${cssUrlEscape(route.picture)}")`;
|
||||
picture.src = route.picture;
|
||||
}
|
||||
|
||||
return card;
|
||||
|
|
@ -428,7 +429,3 @@ function isValidUrl(value) {
|
|||
function formatDate(value) {
|
||||
return new Intl.DateTimeFormat(undefined, { dateStyle: "medium" }).format(new Date(`${value}T00:00:00`));
|
||||
}
|
||||
|
||||
function cssUrlEscape(value) {
|
||||
return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue