Skip to content

Commit 3351217

Browse files
committed
Implement functionality remove featured image
1 parent cdbb27a commit 3351217

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

resources/js/screens/posts/FeaturedImageUploader.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
this.close();
3838
},
3939
40+
/**
41+
* Remove image
42+
*/
43+
removeImage() {
44+
this.imageUrl = null;
45+
this.$emit('removed');
46+
},
47+
4048
4149
/**
4250
* Close the modal.
@@ -76,7 +84,15 @@
7684
<preloader v-if="uploading"></preloader>
7785

7886
<div v-if="imageUrl && !uploading">
79-
<img :src="imageUrl" class="max-w-full">
87+
<div class="relative">
88+
<button @click="removeImage"
89+
class="btn-sm bg-red absolute pin-t pin-r border-black rounded mr-1 mt-1 h-6 w-8 bg-very-light">
90+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
91+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
92+
</svg>
93+
</button>
94+
<img :src="imageUrl" class="max-w-full">
95+
</div>
8096

8197
<div class="input-group">
8298
<label class="input-label">Caption</label>

resources/js/screens/posts/edit.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@
271271
},
272272
273273
274+
/**
275+
* Handle the change event of featured images.
276+
*/
277+
featuredImageRemoved() {
278+
this.form.featured_image = null;
279+
this.form.featured_image_caption = null;
280+
},
281+
282+
274283
/**
275284
* Close the SEO modal.
276285
*/
@@ -507,6 +516,7 @@
507516
<!-- Featured Image Modal -->
508517
<featured-image-uploader :post-id="this.form.id"
509518
@changed="featuredImageChanged"
519+
@removed="featuredImageRemoved"
510520
:current-image-url="form.featured_image"
511521
:current-caption="form.featured_image_caption"></featured-image-uploader>
512522
</div>

0 commit comments

Comments
 (0)