X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-actor-image-edit%2Factor-banner-edit.component.ts;h=47b537b74fbef78b4948da64e81967a5e81fe698;hb=52798aa5f277492d4dd2482bca9396d2e982fa19;hp=08372d8ad04e2f1a499c6f41d88e0033e5cc93fe;hpb=bc529ef7f0e18bef4cb43c0f2345e8fd1c0075ff;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts b/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts index 08372d8ad..47b537b74 100644 --- a/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts +++ b/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts @@ -1,9 +1,10 @@ -import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core' -import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' +import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' +import { SafeResourceUrl } from '@angular/platform-browser' import { Notifier, ServerService } from '@app/core' import { VideoChannel } from '@app/shared/shared-main' import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' import { getBytes } from '@root-helpers/bytes' +import { imageToDataURL } from '@root-helpers/images' @Component({ selector: 'my-actor-banner-edit', @@ -30,26 +31,23 @@ export class ActorBannerEditComponent implements OnInit { preview: SafeResourceUrl constructor ( - private sanitizer: DomSanitizer, private serverService: ServerService, private notifier: Notifier ) { } ngOnInit (): void { - this.serverService.getConfig() - .subscribe(config => { - this.maxBannerSize = config.banner.file.size.max - this.bannerExtensions = config.banner.file.extensions.join(', ') + const config = this.serverService.getHTMLConfig() + this.maxBannerSize = config.banner.file.size.max + this.bannerExtensions = config.banner.file.extensions.join(', ') - // tslint:disable:max-line-length - this.bannerFormat = $localize`ratio 6/1, recommended size: 1920x317, max size: ${getBytes(this.maxBannerSize)}, extensions: ${this.bannerExtensions}` - }) + /* eslint-disable max-len */ + this.bannerFormat = $localize`ratio 6/1, recommended size: 1920x317, max size: ${getBytes(this.maxBannerSize)}, extensions: ${this.bannerExtensions}` } onBannerChange (input: HTMLInputElement) { this.bannerfileInput = new ElementRef(input) - const bannerfile = this.bannerfileInput.nativeElement.files[ 0 ] + const bannerfile = this.bannerfileInput.nativeElement.files[0] if (bannerfile.size > this.maxBannerSize) { this.notifier.error('Error', $localize`This image is too large.`) return @@ -61,7 +59,7 @@ export class ActorBannerEditComponent implements OnInit { this.bannerChange.emit(formData) if (this.previewImage) { - this.preview = this.sanitizer.bypassSecurityTrustResourceUrl(URL.createObjectURL(bannerfile)) + imageToDataURL(bannerfile).then(result => this.preview = result) } }