Skip to content

Commit

Permalink
Merge branch 'feature/image_fix' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Muffo committed Nov 5, 2016
2 parents 3fb4ea0 + 06b8a5b commit b5507cd
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions app/scripts/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,16 @@ function onBoilerpipeArticleExtracted(data, overlay) {

// Replace the preview of the article with the full text
var articlePreviewHTML = contentElement.innerHTML;
contentElement.innerText = articleContent;
contentElement.innerHTML = articleContent;

// Put the image back at the beginning of the article
if (articleImage !== null) {
contentElement.insertBefore(articleImage, contentElement.firstChild);
}
// Clear image styles to fix formatting of images with class/style/width information in article markup
Array.prototype.slice.call(contentElement.querySelectorAll('img')).forEach(function(el) {
el.removeAttribute('class');
el.removeAttribute('width');
el.setAttribute('style', 'max-width:100%;');
});

// Toggle Success Overlay
addUndoButton(articlePreviewHTML);
successOverlay('done', overlay);
}
Expand Down Expand Up @@ -239,6 +242,15 @@ function onMercuryReadabilityArticleExtracted(data, overlay) {
// Replace the preview of the article with the full text
var articlePreviewHTML = contentElement.innerHTML;
contentElement.innerHTML = articleContent;

// Clear image styles to fix formatting of images with class/style/width information in article markup
Array.prototype.slice.call(contentElement.querySelectorAll('img')).forEach(function(el) {
el.removeAttribute('class');
el.removeAttribute('width');
el.setAttribute('style', 'max-width:100%;');
});

// Toggle success overlay
successOverlay('done', overlay);

// Put the image back at the beginning of the article
Expand Down

0 comments on commit b5507cd

Please sign in to comment.