Skip to content

Commit

Permalink
Image path fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvautin committed Nov 3, 2021
1 parent 4dd1097 commit a14b716
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ handlebars = handlebars.create({
timeAgo: (date) => {
return moment(date).fromNow();
},
imagePath: (value) => {
if(value && value.substring(0, 4) === 'http'){
return value;
}
return `${config.baseUrl}${value}`;
},
feather: (icon) => {
// eslint-disable-next-line keyword-spacing
return `<svg
Expand Down
4 changes: 2 additions & 2 deletions views/layouts/layout.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<meta property="og:url" content="{{config.baseUrl}}" />
{{/if}}
{{#if result.productImage}}
<meta property="og:image" content="{{config.baseUrl}}{{result.productImage}}" />
<meta property="og:image" content="{{imagePath result.productImage}}" />
{{/if}}
{{#if productDescription}}
<meta property="og:description" content="{{snip productDescription}}">
Expand Down Expand Up @@ -128,7 +128,7 @@
"gtin": "{{result.productGtin}}",
{{/if}}
{{#if result.productImage}}
"image": "{{config.baseUrl}}{{result.productImage}}",
"image": "{{imagePath result.productImage}}",
{{else}}
"image": "{{config.baseUrl}}uploads/placeholder.png",
{{/if}}
Expand Down
3 changes: 2 additions & 1 deletion views/product-edit.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{> partials/menu}}
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
<form class="form-horizontal" id="productEditForm" data-toggle="validator">
<div class="row">
<div class="col-12">
<div class="page-header">
<div class="float-right">
Expand Down Expand Up @@ -170,7 +171,7 @@
{{#if images}}
<div class="row">
{{#each images}}
<div class="col-sm-3">
<div class="col-sm-3 mt-3">
<p>
<a data-id="{{this.path}}" class="btn-delete-image btn btn-outline-danger">{{ @root.__ "Delete" }}</a>
{{#ifCond this.productImage '==' true}}
Expand Down

0 comments on commit a14b716

Please sign in to comment.