vue-picture-input
vue-picture-input copied to clipboard
How to make a permanent image by default?
Let's imagine a situation:
There is a picture that becomes the default :prefill="brand.book_device_brand_photo"
. The user chose a different picture, but changed his mind and deleted the one he chose. After deleting, you need the image :prefill="brand.book_device_brand_photo"
to come back.
Yes, I agree, this is not the intended behaviour. Please feel free to submit a PR, if you have a solution! :)
In the meantime, I came up with a workaround, since there's a watch on prefill:
<picture-input
ref="photoInput"
:removable="true"
@remove="revert"
:prefill="defaultImage"
:customStrings="{remove:'Revert Image'}" />
Then
methods: {
revert: function() {
this.$refs.photoInput.prefill = null;
this.$nextTick(function() {
this.$refs.photoInput.prefill = this.defaultImage;
});
}
}
In the meantime, I came up with a workaround, since there's a watch on prefill:
<picture-input ref="photoInput" :removable="true" @remove="revert" :prefill="defaultImage" :customStrings="{remove:'Revert Image'}" />
Then
methods: { revert: function() { this.$refs.photoInput.prefill = null; this.$nextTick(function() { this.$refs.photoInput.prefill = this.defaultImage; }); } }
Yeah, I think this workaround is unfortunately the best answer, as I've found more use cases for which is not desirable to change the current behaviour.