Skip to content

Commit f2b3e92

Browse files
nbradburyclaude
andauthored
Don't show featured image when none exists (#22738)
* Start reader improvements feature branch Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Remove content-scanning fallbacks for Reader featured image Only use editorial.image, featured_image, or featured_media.uri as featured image sources instead of scanning post content for suitable images or videos. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Move featured image above title and excerpt in Reader post cards Reorder ConstraintLayout constraints so the visual hierarchy is: blog header → featured image → title → excerpt → interactions → footer Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix grammar in code comments Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b75b514 commit f2b3e92

4 files changed

Lines changed: 8 additions & 25 deletions

File tree

WordPress/src/main/java/org/wordpress/android/models/ReaderCardType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ && new ReaderImageScanner(post.getText(), post.isPrivate)
4747
}
4848

4949
/*
50-
* returns true if the post's content is 100 characters or less
50+
* returns true if the post's content is 100 characters or fewer
5151
*/
5252
private static boolean hasMinContent(@NonNull ReaderPost post) {
5353
if (post.getExcerpt().length() > MIN_CONTENT_CHARS) {

WordPress/src/main/java/org/wordpress/android/models/ReaderPost.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import org.wordpress.android.ui.Organization;
99
import org.wordpress.android.ui.reader.ReaderConstants;
1010
import org.wordpress.android.ui.reader.models.ReaderBlogIdPostId;
11-
import org.wordpress.android.ui.reader.utils.ReaderIframeScanner;
12-
import org.wordpress.android.ui.reader.utils.ReaderImageScanner;
1311
import org.wordpress.android.ui.reader.utils.ReaderUtils;
1412
import org.wordpress.android.util.DateTimeUtilsWrapper;
1513
import org.wordpress.android.util.HtmlUtils;
@@ -204,21 +202,6 @@ public static ReaderPost fromJson(JSONObject json) {
204202
}
205203
}
206204

207-
// if the post doesn't have a featured image but it contains an IMG tag, check whether
208-
// we can find a suitable image from the content
209-
if (!post.hasFeaturedImage() && post.hasImages()) {
210-
post.mFeaturedImage = new ReaderImageScanner(post.mText, post.isPrivate)
211-
.getLargestImage(ReaderConstants.MIN_FEATURED_IMAGE_WIDTH);
212-
}
213-
214-
// if there's no featured image or featured video and the post contains an iframe, scan
215-
// the content for a suitable featured video
216-
if (!post.hasFeaturedImage()
217-
&& !post.hasFeaturedVideo()
218-
&& post.getText().contains("<iframe")) {
219-
post.setFeaturedVideo(new ReaderIframeScanner(post.getText()).getFirstUsableVideo());
220-
}
221-
222205
// "railcar" data - currently used in search streams, used by TrainTracks
223206
JSONObject jsonRailcar = json.optJSONObject("railcar");
224207
if (jsonRailcar != null) {

WordPress/src/main/java/org/wordpress/android/ui/reader/utils/ReaderImageScanner.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ReaderImageScanner(private val content: String, private val isPrivate: Boo
6262
}
6363

6464
/*
65-
* returns true if there at least `minImageCount` images in the post content that are at
65+
* returns true if there is at least `minImageCount` images in the post content that are at
6666
* least `minImageWidth` in size
6767
*/
6868
fun hasUsableImageCount(minImageCount: Int, minImageWidth: Int): Boolean {

WordPress/src/main/res/layout/reader_cardview_post_new.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
android:layout_marginTop="@dimen/margin_medium"
3737
app:layout_constraintStart_toStartOf="parent"
3838
app:layout_constraintEnd_toEndOf="parent"
39-
app:layout_constraintTop_toBottomOf="@id/layout_blog_section"
39+
app:layout_constraintTop_toBottomOf="@id/reader_card_images_bottom_barrier"
4040
app:layout_constraintBottom_toTopOf="@+id/text_excerpt"
4141
tools:text="This the tile of this post - Lorem ipsum dolor sit amet, consectetur adipiscing elit" />
4242

@@ -63,7 +63,7 @@
6363
app:layout_constraintDimensionRatio="16:9"
6464
app:layout_constraintEnd_toEndOf="parent"
6565
app:layout_constraintStart_toStartOf="parent"
66-
app:layout_constraintTop_toBottomOf="@id/text_excerpt"
66+
app:layout_constraintTop_toBottomOf="@id/layout_blog_section"
6767
tools:src="@color/blue_light" />
6868

6969
<ImageView
@@ -90,7 +90,7 @@
9090
android:layout_marginTop="@dimen/margin_medium"
9191
app:layout_constraintStart_toStartOf="parent"
9292
app:layout_constraintEnd_toEndOf="parent"
93-
app:layout_constraintTop_toBottomOf="@id/text_excerpt"
93+
app:layout_constraintTop_toBottomOf="@id/layout_blog_section"
9494
tools:visibility="visible"
9595
tools:layout_height="150dp" />
9696

@@ -112,7 +112,7 @@
112112
app:layout_constraintHorizontal_bias="0"
113113
app:layout_constraintStart_toStartOf="parent"
114114
app:layout_constraintEnd_toStartOf="@id/reader_card_dot_separator"
115-
app:layout_constraintTop_toBottomOf="@id/reader_card_images_bottom_barrier"
115+
app:layout_constraintTop_toBottomOf="@id/text_excerpt"
116116
app:layout_constrainedWidth="true"
117117
tools:text="15 likes" />
118118

@@ -127,7 +127,7 @@
127127
android:importantForAccessibility="no"
128128
app:layout_constraintStart_toEndOf="@id/reader_card_like_count"
129129
app:layout_constraintEnd_toStartOf="@id/reader_card_comment_count"
130-
app:layout_constraintTop_toBottomOf="@id/reader_card_images_bottom_barrier"
130+
app:layout_constraintTop_toBottomOf="@id/text_excerpt"
131131
app:layout_constrainedWidth="true" />
132132

133133
<com.google.android.material.textview.MaterialTextView
@@ -138,7 +138,7 @@
138138
android:layout_marginTop="@dimen/margin_medium"
139139
app:layout_constraintStart_toEndOf="@id/reader_card_dot_separator"
140140
app:layout_constraintEnd_toEndOf="parent"
141-
app:layout_constraintTop_toBottomOf="@id/reader_card_images_bottom_barrier"
141+
app:layout_constraintTop_toBottomOf="@id/text_excerpt"
142142
app:layout_constrainedWidth="true"
143143
tools:text="4 comments" />
144144

0 commit comments

Comments
 (0)