Skip to content

Conversation

nbradbury
Copy link
Contributor

@nbradbury nbradbury commented Jul 20, 2017

Fixes #6279 - the problem was due to choosing a featured image from the post content when the image is still uploading. This resulted in choosing a local file (ex: /storage/emulated/0/Download/IMG_q5m29m.jpg) as a featured image, and the post adapter didn't support displaying device images.

This PR corrects this by supporting device images, and also fixes a few problems in the existing featured image code.

Note: As part of this PR, I added this routine to load resized bitmaps more efficiently than similar routines in ImageUtils. At some point we'll want to move that routine to ImageUtils, but for now I'd like to keep it inside PostListAdapter.

@daniloercoli daniloercoli self-assigned this Jul 21, 2017
imgFeatured.setVisibility(View.VISIBLE);
imgFeatured.setImageUrl(photonUrl, WPNetworkImageView.ImageType.PHOTO);
} else {
Bitmap bmp = fastResizeBitmap(imageUrl, mPhotonWidth);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to not use Bitmap bmp = ImageUtils.getWPImageSpanThumbnailFromFilePath(context, imageUrl, mPhotonWidth); that is well tested and used in the app?

The actual implementation doesn't take in consideration orientation of the pictures, resulting in pictures turned 90° on some devices, and doesn't show the "poster" picture for videos.

if (imageUrl == null) {
imgFeatured.setVisibility(View.GONE);
} else if (imageUrl.startsWith("http")) {
String photonUrl = ReaderUtils.getResizedImageUrl(imageUrl, mPhotonWidth, mPhotonHeight, mSite.isPrivate());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of mSite.isPrivate() should we use SiteUtils.isPhotonCapable(mSite)?
Otherwise self hosted sites can get redirected to Photon.

@nbradbury
Copy link
Contributor Author

@daniloercoli You're right, I should've stuck with the existing image resize. My concern was that since the resizing occurs on the main thread I wanted it to be as fast as possible, and our existing code could be faster. But that's something we should address separately rather than in this PR.

I've updated this PR in 6541dd6 to use the existing method and also switched to using isPhotonCapable, as you suggested.

imageUrl = scanner.getLargestImage();
} else {
imageUrl = null;
imageUrl = new ReaderImageScanner(post.getContent(), mSite.isPrivate()).getLargestImage();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed this in the first pass. Should we use SiteUtils.isPhotonCapable(mSite) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 50f8a8c

@daniloercoli
Copy link
Contributor

:shipit:

@daniloercoli daniloercoli merged commit 31fc97e into develop Jul 24, 2017
@daniloercoli daniloercoli deleted the issue/6279-post-list-missing-featured-image branch July 24, 2017 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Media: featured image is sometimes not shown in Posts list

2 participants