MOBILE-4604 mod_url: Fix embedded URL if it uses pluginfile
parent
eea7ded755
commit
bfc5367a7c
|
@ -19,12 +19,12 @@
|
|||
<ion-list *ngIf="url && !shouldIframe && (!shouldEmbed || !isOther)">
|
||||
<ion-item *ngIf="shouldEmbed">
|
||||
<ion-label>
|
||||
<img *ngIf="isImage" [alt]="name" [src]="url">
|
||||
<img *ngIf="isImage" [alt]="name" [src]="embeddedUrl">
|
||||
<video *ngIf="isVideo" [title]="name" controls controlsList="nodownload">
|
||||
<source [src]="url" [type]="mimetype">
|
||||
<source [src]="embeddedUrl" [type]="mimetype">
|
||||
</video>
|
||||
<audio *ngIf="isAudio" [title]="name" controls>
|
||||
<source [src]="url" [type]="mimetype">
|
||||
<source [src]="embeddedUrl" [type]="mimetype">
|
||||
</audio>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
|
|
|
@ -23,6 +23,7 @@ import { CoreTextUtils } from '@services/utils/text';
|
|||
import { AddonModUrl, AddonModUrlDisplayOptions, AddonModUrlUrl } from '../../services/url';
|
||||
import { AddonModUrlHelper } from '../../services/url-helper';
|
||||
import { ADDON_MOD_URL_COMPONENT } from '../../constants';
|
||||
import { CoreSites } from '@services/sites';
|
||||
|
||||
/**
|
||||
* Component that displays a url.
|
||||
|
@ -38,6 +39,7 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
|
|||
pluginName = 'url';
|
||||
|
||||
url?: string;
|
||||
embeddedUrl?: string;
|
||||
name?: string;
|
||||
shouldEmbed = false;
|
||||
shouldIframe = false;
|
||||
|
@ -137,7 +139,10 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
|
|||
this.shouldEmbed = displayType == CoreConstants.RESOURCELIB_DISPLAY_EMBED;
|
||||
this.shouldIframe = displayType == CoreConstants.RESOURCELIB_DISPLAY_FRAME;
|
||||
|
||||
if (this.shouldEmbed) {
|
||||
if (!this.shouldEmbed) {
|
||||
return;
|
||||
}
|
||||
|
||||
const extension = CoreMimetypeUtils.guessExtensionFromUrl(url.externalurl);
|
||||
|
||||
this.mimetype = CoreMimetypeUtils.getMimeType(extension);
|
||||
|
@ -145,7 +150,11 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
|
|||
this.isAudio = CoreMimetypeUtils.isExtensionInGroup(extension, ['web_audio']);
|
||||
this.isVideo = CoreMimetypeUtils.isExtensionInGroup(extension, ['web_video']);
|
||||
this.isOther = !this.isImage && !this.isAudio && !this.isVideo;
|
||||
}
|
||||
|
||||
// Fix the URL if it uses pluginfile endpoint.
|
||||
const currentSite = CoreSites.getCurrentSite();
|
||||
this.embeddedUrl = currentSite && this.url ?
|
||||
await currentSite.checkAndFixPluginfileURL(this.url) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue