MOBILE-4604 mod_url: Fix embedded URL if it uses pluginfile

main
Dani Palou 2024-06-04 13:12:21 +02:00
parent eea7ded755
commit bfc5367a7c
2 changed files with 20 additions and 11 deletions

View File

@ -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>

View File

@ -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,7 +139,10 @@ 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) {
return;
}
const extension = CoreMimetypeUtils.guessExtensionFromUrl(url.externalurl); const extension = CoreMimetypeUtils.guessExtensionFromUrl(url.externalurl);
this.mimetype = CoreMimetypeUtils.getMimeType(extension); this.mimetype = CoreMimetypeUtils.getMimeType(extension);
@ -145,7 +150,11 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo
this.isAudio = CoreMimetypeUtils.isExtensionInGroup(extension, ['web_audio']); this.isAudio = CoreMimetypeUtils.isExtensionInGroup(extension, ['web_audio']);
this.isVideo = CoreMimetypeUtils.isExtensionInGroup(extension, ['web_video']); this.isVideo = CoreMimetypeUtils.isExtensionInGroup(extension, ['web_video']);
this.isOther = !this.isImage && !this.isAudio && !this.isVideo; 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) : '';
} }
/** /**