Skip to content

Instantly share code, notes, and snippets.

@daniloercoli
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniloercoli/9270134 to your computer and use it in GitHub Desktop.
Save daniloercoli/9270134 to your computer and use it in GitHub Desktop.
diff --git a/src/org/wordpress/android/util/WPHtml.java b/src/org/wordpress/android/util/WPHtml.java
index c320531..c7c9302 100644
--- a/src/org/wordpress/android/util/WPHtml.java
+++ b/src/org/wordpress/android/util/WPHtml.java
@@ -54,6 +54,7 @@ import org.ccil.cowan.tagsoup.HTMLSchema;
import org.ccil.cowan.tagsoup.Parser;
import org.wordpress.android.R;
import org.wordpress.android.WordPress;
+import org.wordpress.android.models.Blog;
import org.wordpress.android.models.MediaFile;
import org.wordpress.android.models.MediaGallery;
import org.wordpress.android.models.Post;
@@ -493,6 +494,18 @@ public class WPHtml {
String title = mediaFile.getTitle();
String caption = mediaFile.getCaption();
int width = mediaFile.getWidth();
+
+
+ try {
+ String localBlogID = imageSpan.getMediaFile().getBlogId();
+ Blog currentBlog = WordPress.wpDB.instantiateBlogByLocalId(Integer.parseInt(localBlogID));
+ // If it's not a gif and blog don't keep original size, there is a chance we need to resize
+ if (!mediaFile.getMimeType().equals("image/gif") && !currentBlog.getMaxImageWidth().equals("Original Size")) {
+ int maxImageWidth = Integer.parseInt(currentBlog.getMaxImageWidth());
+ width = Math.min(width, maxImageWidth);
+ }
+ } catch (Exception e) {
+ }
content = content + "<a href=\"" + url + "\"><img title=\"" + title + "\" "
+ alignmentCSS + "alt=\"image\" src=\"" + url + "?w=" + width +"\" /></a>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment