Merge pull request #3167 from dpalou/MOBILE-3833
MOBILE-3833 filepool: Fix dislay downloaded background imagesmain
commit
f5c9c3d022
|
@ -90,7 +90,7 @@ export class AddonRemoteThemesHandlerService implements CoreStyleHandler {
|
||||||
if (style != '') {
|
if (style != '') {
|
||||||
// Treat the CSS.
|
// Treat the CSS.
|
||||||
CoreUtils.ignoreErrors(
|
CoreUtils.ignoreErrors(
|
||||||
CoreFilepool.treatCSSCode(siteId, fileUrl, style, COMPONENT, 2),
|
CoreFilepool.treatCSSCode(siteId, fileUrl, style, COMPONENT, 1),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,7 +271,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges, O
|
||||||
urls = CoreUtils.uniqueArray(urls); // Remove duplicates.
|
urls = CoreUtils.uniqueArray(urls); // Remove duplicates.
|
||||||
|
|
||||||
const promises = urls.map(async (url) => {
|
const promises = urls.map(async (url) => {
|
||||||
const finalUrl = await CoreFilepool.getUrlByUrl(siteId, url, this.component, this.componentId, 0, true, true);
|
const finalUrl = await CoreFilepool.getSrcByUrl(siteId, url, this.component, this.componentId, 0, true, true);
|
||||||
|
|
||||||
this.logger.debug('Using URL ' + finalUrl + ' for ' + url + ' in inline styles');
|
this.logger.debug('Using URL ' + finalUrl + ' for ' + url + ' in inline styles');
|
||||||
inlineStyles = inlineStyles.replace(new RegExp(url, 'gi'), finalUrl);
|
inlineStyles = inlineStyles.replace(new RegExp(url, 'gi'), finalUrl);
|
||||||
|
|
|
@ -195,6 +195,11 @@ export class CoreSitePluginsHelperProvider {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the schema with the final CSS URL.
|
||||||
|
if (handlerSchema.styles) {
|
||||||
|
handlerSchema.styles.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
// Download the file if not downloaded or the version changed.
|
// Download the file if not downloaded or the version changed.
|
||||||
const path = await CoreFilepool.downloadUrl(
|
const path = await CoreFilepool.downloadUrl(
|
||||||
site.getId(),
|
site.getId(),
|
||||||
|
|
|
@ -2948,7 +2948,7 @@ export class CoreFilepoolProvider {
|
||||||
* and store the result in the CSS file.
|
* and store the result in the CSS file.
|
||||||
*
|
*
|
||||||
* @param siteId Site ID.
|
* @param siteId Site ID.
|
||||||
* @param fileUrl CSS file URL.
|
* @param fileUrl CSS file URL. If a local path is supplied the app will assume it's the path where to write the file.
|
||||||
* @param cssCode CSS code.
|
* @param cssCode CSS code.
|
||||||
* @param component The component to link the file to.
|
* @param component The component to link the file to.
|
||||||
* @param componentId An ID to use in conjunction with the component.
|
* @param componentId An ID to use in conjunction with the component.
|
||||||
|
@ -2966,29 +2966,33 @@ export class CoreFilepoolProvider {
|
||||||
const urls = CoreDomUtils.extractUrlsFromCSS(cssCode);
|
const urls = CoreDomUtils.extractUrlsFromCSS(cssCode);
|
||||||
let updated = false;
|
let updated = false;
|
||||||
|
|
||||||
// Get the path of the CSS file.
|
// Get the path of the CSS file. If it's a local file, assume it's the path where to write the file.
|
||||||
const filePath = await this.getFilePathByUrl(siteId, fileUrl);
|
const filePath = CoreUrlUtils.isLocalFileUrl(fileUrl) ?
|
||||||
|
fileUrl :
|
||||||
|
await this.getFilePathByUrl(siteId, fileUrl);
|
||||||
|
|
||||||
// Download all files in the CSS.
|
// Download all files in the CSS.
|
||||||
await Promise.all(urls.map(async (url) => {
|
await Promise.all(urls.map(async (url) => {
|
||||||
// Download the file only if it's an online URL.
|
|
||||||
if (CoreUrlUtils.isLocalFileUrl(url)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fileUrl = await this.downloadUrl(
|
let fileUrl = url;
|
||||||
siteId,
|
if (!CoreUrlUtils.isLocalFileUrl(url)) {
|
||||||
url,
|
// Not a local file, download it.
|
||||||
false,
|
fileUrl = await this.downloadUrl(
|
||||||
component,
|
siteId,
|
||||||
componentId,
|
url,
|
||||||
0,
|
false,
|
||||||
undefined,
|
component,
|
||||||
undefined,
|
componentId,
|
||||||
undefined,
|
0,
|
||||||
revision,
|
undefined,
|
||||||
);
|
undefined,
|
||||||
|
undefined,
|
||||||
|
revision,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert the URL so it works in mobile devices.
|
||||||
|
fileUrl = CoreFile.convertFileSrc(fileUrl);
|
||||||
|
|
||||||
if (fileUrl != url) {
|
if (fileUrl != url) {
|
||||||
cssCode = cssCode.replace(new RegExp(CoreTextUtils.escapeForRegex(url), 'g'), fileUrl);
|
cssCode = cssCode.replace(new RegExp(CoreTextUtils.escapeForRegex(url), 'g'), fileUrl);
|
||||||
|
|
Loading…
Reference in New Issue