forked from UKSOURCE/cms.hailearning.edu.vn
refactor: remove camp location functionality
This commit is contained in:
@@ -72,7 +72,7 @@
|
||||
</div>
|
||||
<div id="featuredImagePreview" class="mt-2">
|
||||
<% if (blog.featuredImage) { %>
|
||||
<img src="<%= blog.featuredImage %>"
|
||||
<img src="<%= getFullImageUrl(blog.featuredImage, backendUrl) %>"
|
||||
class="img-thumbnail"
|
||||
style="max-width: 300px; max-height: 200px; object-fit: cover;"
|
||||
alt="Featured image preview">
|
||||
@@ -134,7 +134,7 @@
|
||||
</div>
|
||||
<div id="galleryPreview_0" class="mt-2">
|
||||
<% if (image1) { %>
|
||||
<img src="<%= image1 %>"
|
||||
<img src="<%= getFullImageUrl(image1, backendUrl) %>"
|
||||
class="img-thumbnail"
|
||||
style="max-width: 200px; max-height: 150px; object-fit: cover;"
|
||||
alt="Gallery image 1 preview">
|
||||
@@ -157,7 +157,7 @@
|
||||
</div>
|
||||
<div id="galleryPreview_1" class="mt-2">
|
||||
<% if (image2) { %>
|
||||
<img src="<%= image2 %>"
|
||||
<img src="<%= getFullImageUrl(image2, backendUrl) %>"
|
||||
class="img-thumbnail"
|
||||
style="max-width: 200px; max-height: 150px; object-fit: cover;"
|
||||
alt="Gallery image 2 preview">
|
||||
@@ -958,11 +958,23 @@
|
||||
input.value = result.path;
|
||||
|
||||
// Show preview
|
||||
const backendUrl = '<%= typeof backendUrl !== "undefined" ? backendUrl : "http://localhost:3001" %>';
|
||||
const getFullImageUrl = function(imagePath, baseUrl) {
|
||||
if (!imagePath) return "";
|
||||
if (imagePath.startsWith("http://") || imagePath.startsWith("https://")) {
|
||||
return imagePath;
|
||||
}
|
||||
const base = (baseUrl || "http://localhost:3001").replace(/\/$/, "");
|
||||
let imgSrc = imagePath;
|
||||
if (!imgSrc.startsWith("/")) {
|
||||
imgSrc = "/" + imgSrc;
|
||||
}
|
||||
return base + imgSrc;
|
||||
};
|
||||
|
||||
if (targetInput === 'featuredImageUrl') {
|
||||
const preview = document.getElementById('featuredImagePreview');
|
||||
const previewUrl = (result.path && (result.path.startsWith('http://') || result.path.startsWith('https://')))
|
||||
? result.path
|
||||
: (window.location.origin + result.path);
|
||||
const previewUrl = getFullImageUrl(result.path, backendUrl);
|
||||
preview.innerHTML = `
|
||||
<img src="${previewUrl}" class="img-thumbnail"
|
||||
style="max-width: 300px; max-height: 200px; object-fit: cover;"
|
||||
@@ -972,9 +984,7 @@
|
||||
const index = targetInput.split('_')[1];
|
||||
const preview = document.getElementById(`galleryPreview_${index}`);
|
||||
if (preview) {
|
||||
const previewUrl = (result.path && (result.path.startsWith('http://') || result.path.startsWith('https://')))
|
||||
? result.path
|
||||
: (window.location.origin + result.path);
|
||||
const previewUrl = getFullImageUrl(result.path, backendUrl);
|
||||
preview.innerHTML = `
|
||||
<img src="${previewUrl}" class="img-thumbnail"
|
||||
style="max-width: 200px; max-height: 150px; object-fit: cover;"
|
||||
|
||||
Reference in New Issue
Block a user