Skip to content

Commit a42ed63

Browse files
committed
fix image handling during generation (PnX-SI#110)
1 parent d0a3a83 commit a42ed63

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
**🐛 Corrections**
88

9+
- Correction de la gestion des images lors de la génération (#110, by @juggler31)
10+
911
## 1.4.0 - La Narse de Nouvialle (2025-03-27)
1012

1113
Compatibilité avec GeoNature 2.15.0 minimum.

backend/gn_module_zh/blueprint.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66
from urllib.parse import urljoin
77

88
import sqlalchemy.exc as exc
9-
from flask import Blueprint, Response, jsonify, request, send_file, g
9+
from flask import (
10+
Blueprint,
11+
Response,
12+
jsonify,
13+
request,
14+
send_file,
15+
g,
16+
current_app,
17+
send_from_directory,
18+
)
1019
from flask.helpers import send_file
1120
from geojson import FeatureCollection
1221
from werkzeug.exceptions import Forbidden, BadRequest, NotFound
@@ -86,6 +95,12 @@
8695
blueprint = Blueprint("pr_zh", __name__, "./static", template_folder="templates")
8796

8897

98+
# Route pour retourner les images téléversées dans les pdf
99+
@blueprint.route("/media/attachment/<path:filename>")
100+
def media_attachment(filename):
101+
return send_from_directory(current_app.config["MEDIA_FOLDER"] + "/attachments", filename)
102+
103+
89104
# Route pour afficher liste des zones humides
90105
@blueprint.route("", methods=["GET", "POST"])
91106
@permissions.check_cruved_scope("R", get_scope=True, module_code="ZONES_HUMIDES")

backend/gn_module_zh/templates/milieux.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h5 class="subtitle">Corine Biotope</h5>
2929
{% if data['image_name'] is not none %}
3030
<div class="right">
3131
<section class="content"></section>
32-
<img class="image" src="{{ url_for('pr_zh.static', filename=data['image_name']) }}">
32+
<img class="image" src="{{ url_for('pr_zh.media_attachment', filename=data['image_name']) }}">
3333
</section>
3434
</div>
3535
{% endif %}

0 commit comments

Comments
 (0)