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-list *ngIf="url && !shouldIframe && (!shouldEmbed || !isOther)">
|
||||||
<ion-item *ngIf="shouldEmbed">
|
<ion-item *ngIf="shouldEmbed">
|
||||||
<ion-label>
|
<ion-label>
|
||||||
<img *ngIf="isImage" [alt]="name" [src]="url">
|
<img *ngIf="isImage" [alt]="name" [src]="embeddedUrl">
|
||||||
<video *ngIf="isVideo" [title]="name" controls controlsList="nodownload">
|
<video *ngIf="isVideo" [title]="name" controls controlsList="nodownload">
|
||||||
<source [src]="url" [type]="mimetype">
|
<source [src]="embeddedUrl" [type]="mimetype">
|
||||||
</video>
|
</video>
|
||||||
<audio *ngIf="isAudio" [title]="name" controls>
|
<audio *ngIf="isAudio" [title]="name" controls>
|
||||||
<source [src]="url" [type]="mimetype">
|
<source [src]="embeddedUrl" [type]="mimetype">
|
||||||
</audio>
|
</audio>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
|
@ -23,6 +23,7 @@ import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { AddonModUrl, AddonModUrlDisplayOptions, AddonModUrlUrl } from '../../services/url';
|
import { AddonModUrl, AddonModUrlDisplayOptions, AddonModUrlUrl } from '../../services/url';
|
||||||
import { AddonModUrlHelper } from '../../services/url-helper';
|
import { AddonModUrlHelper } from '../../services/url-helper';
|
||||||
import { ADDON_MOD_URL_COMPONENT } from '../../constants';
|
import { ADDON_MOD_URL_COMPONENT } from '../../constants';
|
||||||
|
import { CoreSites } from '@services/sites';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays a url.
|
* Component that displays a url.
|
||||||
|
@ -38,6 +39,7 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
|
||||||
pluginName = 'url';
|
pluginName = 'url';
|
||||||
|
|
||||||
url?: string;
|
url?: string;
|
||||||
|
embeddedUrl?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
shouldEmbed = false;
|
shouldEmbed = false;
|
||||||
shouldIframe = false;
|
shouldIframe = false;
|
||||||
|
@ -137,15 +139,22 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
|
||||||
this.shouldEmbed = displayType == CoreConstants.RESOURCELIB_DISPLAY_EMBED;
|
this.shouldEmbed = displayType == CoreConstants.RESOURCELIB_DISPLAY_EMBED;
|
||||||
this.shouldIframe = displayType == CoreConstants.RESOURCELIB_DISPLAY_FRAME;
|
this.shouldIframe = displayType == CoreConstants.RESOURCELIB_DISPLAY_FRAME;
|
||||||
|
|
||||||
if (this.shouldEmbed) {
|
if (!this.shouldEmbed) {
|
||||||
const extension = CoreMimetypeUtils.guessExtensionFromUrl(url.externalurl);
|
return;
|
||||||
|
|
||||||
this.mimetype = CoreMimetypeUtils.getMimeType(extension);
|
|
||||||
this.isImage = CoreMimetypeUtils.isExtensionInGroup(extension, ['web_image']);
|
|
||||||
this.isAudio = CoreMimetypeUtils.isExtensionInGroup(extension, ['web_audio']);
|
|
||||||
this.isVideo = CoreMimetypeUtils.isExtensionInGroup(extension, ['web_video']);
|
|
||||||
this.isOther = !this.isImage && !this.isAudio && !this.isVideo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const extension = CoreMimetypeUtils.guessExtensionFromUrl(url.externalurl);
|
||||||
|
|
||||||
|
this.mimetype = CoreMimetypeUtils.getMimeType(extension);
|
||||||
|
this.isImage = CoreMimetypeUtils.isExtensionInGroup(extension, ['web_image']);
|
||||||
|
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