vue-picture-input icon indicating copy to clipboard operation
vue-picture-input copied to clipboard

How to make a permanent image by default?

Open maksimklimenko opened this issue 2 years ago • 2 comments

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.

maksimklimenko avatar May 16 '22 04:05 maksimklimenko

Yes, I agree, this is not the intended behaviour. Please feel free to submit a PR, if you have a solution! :)

alessiomaffeis avatar May 16 '22 14:05 alessiomaffeis

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;
    });
  }
}

tyrrminal avatar Jun 09 '22 14:06 tyrrminal

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.

alessiomaffeis avatar Jul 20 '23 19:07 alessiomaffeis