correction du traitement des urls des images dans les différents contenus
This commit is contained in:
parent
31d611267a
commit
dd154c632d
@ -39,7 +39,7 @@ $siteStats = $stats->getStats();
|
|||||||
<!-- Contenu principal -->
|
<!-- Contenu principal -->
|
||||||
<div class="about-content">
|
<div class="about-content">
|
||||||
<div class="about-description">
|
<div class="about-description">
|
||||||
<?= $about['content'] // Le contenu est déjà en HTML ?>
|
<?= $about['content'] = Config::fixImagePaths($about['content']); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<aside class="sidebar">
|
<aside class="sidebar">
|
||||||
|
@ -82,7 +82,7 @@ class AboutImageUploadHandler {
|
|||||||
// Retourner le chemin relatif pour l'éditeur
|
// Retourner le chemin relatif pour l'éditeur
|
||||||
return [
|
return [
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'url' => '../assets/images/about/' . $filename,
|
'url' => 'assets/images/about/' . $filename,
|
||||||
'width' => $needsResize ? $newWidth : $width,
|
'width' => $needsResize ? $newWidth : $width,
|
||||||
'height' => $needsResize ? $newHeight : $height
|
'height' => $needsResize ? $newHeight : $height
|
||||||
];
|
];
|
||||||
|
@ -81,9 +81,12 @@ class ImageUploadHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retourner le chemin relatif pour l'éditeur
|
// Retourner le chemin relatif pour l'éditeur
|
||||||
|
$relativePath = $this->getRelativePath($targetPath);
|
||||||
|
$adminPreviewPath = '../' . $relativePath;
|
||||||
return [
|
return [
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'url' => $this->getRelativePath($targetPath),
|
'url' => $adminPreviewPath,
|
||||||
|
'storage_url' => $relativePath,
|
||||||
'width' => $needsResize ? $newWidth : $width,
|
'width' => $needsResize ? $newWidth : $width,
|
||||||
'height' => $needsResize ? $newHeight : $height
|
'height' => $needsResize ? $newHeight : $height
|
||||||
];
|
];
|
||||||
@ -149,9 +152,7 @@ class ImageUploadHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function getRelativePath($absolutePath) {
|
private function getRelativePath($absolutePath) {
|
||||||
$relativePath = str_replace(__DIR__ . '/../../', '', $absolutePath);
|
return str_replace(__DIR__ . '/../../', '', $absolutePath);
|
||||||
// Ajout de '../' car on est dans admin/api/
|
|
||||||
return '../' . str_replace('\\', '/', $relativePath); // Pour la compatibilité Windows
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getUploadErrorMessage($error) {
|
private function getUploadErrorMessage($error) {
|
||||||
|
@ -537,6 +537,15 @@ body {
|
|||||||
padding: var(--spacing-lg);
|
padding: var(--spacing-lg);
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.about-description img {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
display: block;
|
||||||
|
margin: var(--spacing-md) 0;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sidebar */
|
/* Sidebar */
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const storyId = document.querySelector('input[name="id"]')?.value || urlParams.get('id');
|
||||||
let currentChapterId = null;
|
let currentChapterId = null;
|
||||||
const storyId = document.querySelector('input[name="id"]')?.value;
|
|
||||||
|
|
||||||
// Fonction de notification
|
// Fonction de notification
|
||||||
function showNotification(message, type = 'success') {
|
function showNotification(message, type = 'success') {
|
||||||
@ -96,6 +97,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
if (result.success) {
|
if (result.success) {
|
||||||
const range = quill.getSelection(true);
|
const range = quill.getSelection(true);
|
||||||
quill.insertEmbed(range.index, 'image', result.url);
|
quill.insertEmbed(range.index, 'image', result.url);
|
||||||
|
const insertOp = quill.getContents().ops.find(op =>
|
||||||
|
op.insert && op.insert.image === result.url
|
||||||
|
);
|
||||||
|
if (insertOp) {
|
||||||
|
insertOp.insert.image = result.storage_url;
|
||||||
|
}
|
||||||
quill.setSelection(range.index + 1);
|
quill.setSelection(range.index + 1);
|
||||||
} else {
|
} else {
|
||||||
showNotification(result.error || 'Erreur lors de l\'upload', 'error');
|
showNotification(result.error || 'Erreur lors de l\'upload', 'error');
|
||||||
|
@ -68,7 +68,7 @@ $config = Config::load();
|
|||||||
<!-- Contenu principal -->
|
<!-- Contenu principal -->
|
||||||
<div class="novel-content">
|
<div class="novel-content">
|
||||||
<div class="novel-description chapter-content">
|
<div class="novel-description chapter-content">
|
||||||
<?= $currentChapter['content'] ?>
|
<?= $currentChapter['content'] = Config::fixImagePaths($currentChapter['content']); ?>
|
||||||
|
|
||||||
<!-- Navigation entre chapitres -->
|
<!-- Navigation entre chapitres -->
|
||||||
<div class="chapter-navigation">
|
<div class="chapter-navigation">
|
||||||
|
@ -31,6 +31,10 @@ class Config {
|
|||||||
return $config[$key] ?? $default;
|
return $config[$key] ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function fixImagePaths($content) {
|
||||||
|
return preg_replace('/(src|url)=(["\'])\.\.\//i', '$1=$2', $content);
|
||||||
|
}
|
||||||
|
|
||||||
public static function save($newConfig) {
|
public static function save($newConfig) {
|
||||||
$configFile = __DIR__ . '/../config.json';
|
$configFile = __DIR__ . '/../config.json';
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ $config = Config::load();
|
|||||||
<!-- Contenu principal -->
|
<!-- Contenu principal -->
|
||||||
<div class="novel-content">
|
<div class="novel-content">
|
||||||
<div class="novel-description">
|
<div class="novel-description">
|
||||||
<?= $story['description'] ?>
|
<?= $story['description'] = Config::fixImagePaths($story['description']); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<aside class="chapters-menu">
|
<aside class="chapters-menu">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user