Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embeds: Use native <img> instead of <amp-img> #10219

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions includes/Renderer/Stories/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,26 +591,14 @@ protected function render_story_with_poster() {
?>
<div class="web-stories-list__story-poster">
<a href="<?php echo esc_url( $story->get_url() ); ?>">
<?php
if ( $this->context->is_amp() ) {
// Set the dimensions to '0' so that we can handle image ratio/size by CSS per view type.
?>
<amp-img
src="<?php echo esc_url( $poster_url ); ?>"
layout="responsive"
width="0"
height="0"
alt="<?php echo esc_attr( $story->get_title() ); ?>"
>
</amp-img>
<?php } else { ?>
<img
src="<?php echo esc_url( $poster_url ); ?>"
alt="<?php echo esc_attr( $story->get_title() ); ?>"
width="<?php echo absint( $this->width ); ?>"
height="<?php echo absint( $this->height ); ?>"
>
<?php } ?>
<img
src="<?php echo esc_url( $poster_url ); ?>"
alt="<?php echo esc_attr( $story->get_title() ); ?>"
width="<?php echo absint( $this->width ); ?>"
height="<?php echo absint( $this->height ); ?>"
loading="lazy"
decoding="async"
Comment on lines +599 to +600
Copy link
Contributor

Choose a reason for hiding this comment

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

These changes to reasonable to me, but just want to confirm adding these attributes is the right thing. CC @swissspidy

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. Without these it would be invalid AMP. I explicitly mentioned these in #10213 as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just confirming, no need to thumbs down 😢 . Should, implies some wiggle room, if it needs it, maybe you that wording.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I swear this was meant to be a thumbs up

>
</a>
</div>
<?php
Expand Down
5 changes: 0 additions & 5 deletions packages/stories-block/src/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@
box-sizing: border-box;
}

.web-stories-list__story-poster amp-img img {
object-fit: cover;
box-sizing: border-box;
}

.web-stories-list__story-poster::before {
content: '';
display: block;
Expand Down
6 changes: 1 addition & 5 deletions packages/stories-block/src/css/views/circles.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
.web-stories-list__story-poster
.web-stories-list__story-poster-placeholder,
.web-stories-list.is-view-type-circles .web-stories-list__story-poster > img,
.web-stories-list.is-view-type-circles .web-stories-list__story-poster a > img,
.web-stories-list.is-view-type-circles
.web-stories-list__story-poster
a
> amp-img {
.web-stories-list.is-view-type-circles .web-stories-list__story-poster a > img {
position: absolute;
top: 0;
left: 0;
Expand Down