Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions static/css/dashboard_update.css
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,12 +80,16 @@
text-align: center;
}

.d_service > img {
.d_service > label {
display: block;
}

.d_service > label > img {
max-width: 500px;
width: 100%;
}

.project_image {
label > .project_image {
border-radius: 25px;
}

Expand Down
10 changes: 10 additions & 0 deletions static/js/dashboard_update.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
document.getElementById("project_image").addEventListener("change", function () {
const file = this.files[0];
if (file) {
const reader = new FileReader();
reader.onload = (e) => {
document.getElementById("preview_image").src = e.target.result;
};
reader.readAsDataURL(file);
}
});
8 changes: 6 additions & 2 deletions templates/projects/dashboard_update.html
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,11 +13,14 @@
{% csrf_token %}

<div class="d_service">
<label for="project_image" style="cursor: pointer;">
{% if project.project_image %}
<img src="{{ project.project_image.url }}" alt="서비스이미지" class="project_image">
<img src="{{ project.project_image.url }}" alt="서비스이미지" class="project_image" id="preview_image">
{% else %}
<img src="{% static 'images/service_default.png' %}" alt="서비스이미지">
<img src="{% static 'images/service_default.png' %}" alt="서비스이미지" id="preview_image">
{% endif %}
</label>
<input type="file" id="project_image" name="project_image" accept="image/*" style="display:none;">
<input type="text" name="title" value="{{ project.title }}" class="title_input" required>
<textarea name="description" class="description_input" required>{{ project.description }}</textarea>
</div>
Expand DownExpand Up@@ -140,4 +143,5 @@ <h3>전체</h3>
<button type="submit">저장하기</button>
</form>
</div>
<script defer src="{% static 'js/dashboard_update.js' %}"></script>
{% endblock %}