Skip to content
This repository has been archived by the owner on Oct 10, 2018. It is now read-only.

Plugin Issue #864: Remove <amp-img> workaround filters. #81

Merged
merged 8 commits into from
Apr 4, 2018
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
2 changes: 1 addition & 1 deletion assets/dist/css/main.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions assets/src/css/components/_entry--featured.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
width: 100%;
margin: -10px 0 0;
}

.wp-post-image {
padding-bottom: 38%;
}
}

//
Expand Down
10 changes: 10 additions & 0 deletions assets/src/css/components/_entry.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
&__thumbnail {
margin: 0;
padding: 0;

.wp-post-image {
position: relative;
width: 100%;
padding-bottom: 66%;
}

img {
object-fit: cover;
}
}

//
Expand Down
17 changes: 16 additions & 1 deletion assets/src/css/components/_site-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,25 @@
width: 100%;
max-width: 400px;
height: 100%;
background-repeat: no-repeat;
background-position: left center;
background-size: contain;

@media ( query( min, tablet ) ) {
height: auto;
}
}

.custom-logo {
max-width: 100%;
max-height: 100%;

@media ( query( min, tablet ) ) {
display: block;
}

img {
object-fit: contain;
}
}
}

Expand Down
42 changes: 0 additions & 42 deletions inc/template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,45 +68,3 @@ function ampconf_get_the_archive_title( $title ) {
return $title;
}
add_filter( 'get_the_archive_title', 'ampconf_get_the_archive_title' );

/**
* Filter the featured image for AMP.
*
* There is a problem with the AMP sanitizer that is not properly converting img into amp-img,
* so this is a workaround to preempt the sanitizer.
*
* @see get_the_post_thumbnail()
*
* @param string $html The post thumbnail HTML.
* @return string Amplified HTML.
*/
function ampconf_filter_post_thumbnail_html( $html ) {
if ( is_amp_endpoint() ) {
$html = str_replace( '<img ', '<amp-img ', $html ) . '</amp-img>';
}
return $html;
}
if ( function_exists( 'is_amp_endpoint' ) ) {
add_filter( 'post_thumbnail_html', 'ampconf_filter_post_thumbnail_html' );
}

/**
* Filter the custom logo image for AMP.
*
* There is a problem with the AMP sanitizer that is not properly converting img into amp-img,
* so this is a workaround to preempt the sanitizer.
*
* @see get_custom_logo()
*
* @param string $html The custom logo HTML.
* @return string Amplified HTML.
*/
function ampconf_filter_get_custom_logo( $html ) {
if ( is_amp_endpoint() ) {
$html = str_replace( '<img ', '<amp-img ', $html ) . '</amp-img>';
}
return $html;
}
if ( function_exists( 'is_amp_endpoint' ) ) {
add_filter( 'get_custom_logo', 'ampconf_filter_get_custom_logo' );
}
2 changes: 1 addition & 1 deletion templates/entry/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<?php if ( has_post_thumbnail() ) : ?>
<figure class="entry__thumbnail">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( 'ampconf-768x432' ); ?>
<?php the_post_thumbnail( 'ampconf-768x432', array( 'data-amp-layout' => 'fill' ) ); ?>
</a>
</figure><!-- .entry__thumbnail -->
<?php endif; ?>
Expand Down
2 changes: 1 addition & 1 deletion templates/entry/featured.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<?php if ( has_post_thumbnail() ) : ?>
<figure class="entry__thumbnail">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( 'ampconf-1040x585' ); ?>
<?php the_post_thumbnail( 'ampconf-1040x585', array( 'data-amp-layout' => 'fill' ) ); ?>
</a>
</figure><!-- .entry__thumbnail -->
<?php endif; ?>
Expand Down
2 changes: 1 addition & 1 deletion templates/entry/full-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<?php if ( has_post_thumbnail() ) : ?>
<figure class="entry__thumbnail">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( 'ampconf-1040x585' ); ?>
<?php the_post_thumbnail( 'ampconf-1040x585', array( 'data-amp-layout' => 'fill' ) ); ?>
</a>
</figure><!-- .entry__thumbnail -->
<?php endif; ?>
Expand Down
2 changes: 1 addition & 1 deletion templates/entry/full.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<?php if ( has_post_thumbnail() ) : ?>
<figure class="entry__thumbnail">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( 'ampconf-1040x585' ); ?>
<?php the_post_thumbnail( 'ampconf-1040x585', array( 'data-amp-layout' => 'fill' ) ); ?>
</a>
</figure><!-- .entry__thumbnail -->
<?php endif; ?>
Expand Down
2 changes: 1 addition & 1 deletion templates/entry/slim.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<?php if ( has_post_thumbnail() ) : ?>
<figure class="entry__thumbnail">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( 'ampconf-280x158' ); ?>
<?php the_post_thumbnail( 'ampconf-280x158', array( 'data-amp-layout' => 'fill' ) ); ?>
</a>
</figure><!-- .entry__thumbnail -->
<?php endif; ?>
Expand Down