forked from UKSOURCE/cms.hailearning.edu.vn
refactor: remove camp location functionality
This commit is contained in:
@@ -540,10 +540,25 @@
|
||||
// Lưu đúng relative path vào input (ví dụ: /uploads/blog/xxx.png)
|
||||
input.value = result.path;
|
||||
|
||||
// Show preview sử dụng đúng data gốc (không gắn thêm URL)
|
||||
// Helper function để tạo full URL
|
||||
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;
|
||||
};
|
||||
|
||||
// Show preview sử dụng helper function
|
||||
if (targetInput === 'featuredImageUrl') {
|
||||
const preview = document.getElementById('featuredImagePreview');
|
||||
const previewUrl = 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;"
|
||||
@@ -553,7 +568,7 @@
|
||||
const index = targetInput.split('_')[1];
|
||||
const preview = document.getElementById(`galleryPreview_${index}`);
|
||||
if (preview) {
|
||||
const previewUrl = 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