Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I change image preview background #52

Closed
lelikflegma opened this issue Apr 13, 2020 · 3 comments
Closed

How can I change image preview background #52

lelikflegma opened this issue Apr 13, 2020 · 3 comments

Comments

@lelikflegma
Copy link

Hi. Currently, when I upload image, preview background-color is calculated and settled like average color of uploaded image. So, for original PNG, with transparent body
image
I got :
image

I found in html this :

<span class="file-preview image-preview" style="background-color: rgb(80, 65, 250);">

When i comment style, i got this :
image

For remove gray backround i can override css property "background" in :

.vue-file-agent .file-category-video-playable .file-preview .file-preview-overlay, .vue-file-agent .file-preview-wrapper-image .file-preview .file-preview-overlay {...}

image

and for remove grid :

.vue-file-agent .file-preview .file-preview-img {...}

image

But how can I remove setting "average" color background ?

In source code i found function :

public color(): string {
    if (this.imageColor) {
      const rgb = this.imageColor;
      return 'rgb(' + rgb[0] + ', ' + rgb[1] + ', ' + rgb[2] + ')';
    }
    if (this.isImage()) {
      return 'transparent';
    }
    const ext = this.ext();
    const svgIcon = this.icon();
    // var svgIcon = getIconFromExt(ext);
    if (svgIcon.color) {
      return svgIcon.color;
    }
    return utils.getColorForText(ext);
  }

And property imageColor :

imageColor: RGBA;
@safrazik
Copy link
Owner

I think, having a property to disable this feature will be the ideal solution for this. But for the time being, you can use a CSS workaround. Note the usage of !important

.vue-file-agent .file-category-video-playable .file-preview,
.vue-file-agent .file-preview-wrapper-image .file-preview {
  background: transparent !important;
}

@lelikflegma
Copy link
Author

Yes it works like that, thanks.
But having property will be better.

@safrazik
Copy link
Owner

Yes, with the property, the operation to calculate the average color can be avoided too.

Instead of transparent background you can try other colors like white and black too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants