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

Refines handling of 0 and empty height/width attributes #979

Merged
merged 9 commits into from Feb 27, 2018

Conversation

Projects
None yet
3 participants
@davisshaver
Contributor

davisshaver commented Feb 26, 2018

Alternate branch of #978 (comment) w/ spacing update.

Fixes #974

@westonruter

This comment has been minimized.

Show comment
Hide comment
@westonruter

westonruter Feb 26, 2018

Collaborator

@davisshaver in #974 you call out numbers with decimals specifically but I don't see any tests that have float dimensions.

Collaborator

westonruter commented Feb 26, 2018

@davisshaver in #974 you call out numbers with decimals specifically but I don't see any tests that have float dimensions.

@davisshaver

This comment has been minimized.

Show comment
Hide comment
@davisshaver

davisshaver Feb 26, 2018

Contributor

opps! fixing..

Contributor

davisshaver commented Feb 26, 2018

opps! fixing..

@davisshaver

This comment has been minimized.

Show comment
Hide comment
@davisshaver

davisshaver Feb 26, 2018

Contributor

@westonruter Updated, sry about that.

Contributor

davisshaver commented Feb 26, 2018

@westonruter Updated, sry about that.

Show outdated Hide outdated includes/sanitizers/class-amp-base-sanitizer.php
Show outdated Hide outdated includes/sanitizers/class-amp-base-sanitizer.php
$node->setAttribute( 'class', $class );
} elseif (
! is_numeric( $node->getAttribute( 'width' ) )
) {

This comment has been minimized.

@westonruter

westonruter Feb 26, 2018

Collaborator

Indentation of this elseif line is inconsistent with the previous multi-line elseif.

@westonruter

westonruter Feb 26, 2018

Collaborator

Indentation of this elseif line is inconsistent with the previous multi-line elseif.

'image_with_zero_width' => array(
'<p><img src="http://placehold.it/300x300" width="0" height="300" /></p>',
'<p><amp-img src="http://placehold.it/300x300" width="0" height="300" sizes="(min-width: 0px) 0px, 100vw" class="amp-wp-enforced-sizes"></amp-img></p>',
),

This comment has been minimized.

@westonruter

westonruter Feb 26, 2018

Collaborator

Please also include a test with a zero width and height so we can ensure that the support topic is covered:

<img src="https://example.com/img.jpg" width="0" height="0" border="0">
@westonruter

westonruter Feb 26, 2018

Collaborator

Please also include a test with a zero width and height so we can ensure that the support topic is covered:

<img src="https://example.com/img.jpg" width="0" height="0" border="0">

This comment has been minimized.

@westonruter

westonruter Feb 27, 2018

Collaborator

Could you add a test for this?

@westonruter

westonruter Feb 27, 2018

Collaborator

Could you add a test for this?

This comment has been minimized.

@davisshaver

davisshaver Feb 27, 2018

Contributor

Done ✔️

@davisshaver

davisshaver Feb 27, 2018

Contributor

Done ✔️

@davisshaver

This comment has been minimized.

Show comment
Hide comment
@davisshaver

davisshaver Feb 26, 2018

Contributor

Thanks for the review, will clean this up tomorrow AM!

Contributor

davisshaver commented Feb 26, 2018

Thanks for the review, will clean this up tomorrow AM!

@davisshaver

This comment has been minimized.

Show comment
Hide comment
@davisshaver

davisshaver Feb 27, 2018

Contributor

@westonruter all set for another 👀 ! Much appreciated

Contributor

davisshaver commented Feb 27, 2018

@westonruter all set for another 👀 ! Much appreciated

@westonruter westonruter changed the title from Refines handling of 0 and unset height/width attrs [With spacing update] to Refines handling of 0 and empty height/width attributes Feb 27, 2018

@westonruter westonruter merged commit 23eced6 into Automattic:develop Feb 27, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sach-patel

This comment has been minimized.

Show comment
Hide comment
@sach-patel

sach-patel Mar 15, 2018

Found this while searching for a solution where images have fractional value for the height property. It is weird but it happened during migration from Drupal to WP. Is there any way to tackle such images? Thanks.

sach-patel commented Mar 15, 2018

Found this while searching for a solution where images have fractional value for the height property. It is weird but it happened during migration from Drupal to WP. Is there any way to tackle such images? Thanks.

@westonruter

This comment has been minimized.

Show comment
Hide comment
@westonruter

westonruter Mar 15, 2018

Collaborator

@sach-patel I wasn't able to see floats causing any validation errors.

Collaborator

westonruter commented Mar 15, 2018

@sach-patel I wasn't able to see floats causing any validation errors.

@westonruter

This comment has been minimized.

Show comment
Hide comment
@westonruter

westonruter Mar 20, 2018

Collaborator

@davisshaver I have a related bug if you're interested: #1030

Collaborator

westonruter commented Mar 20, 2018

@davisshaver I have a related bug if you're interested: #1030

@sach-patel

This comment has been minimized.

Show comment
Hide comment
@sach-patel

sach-patel Mar 28, 2018

@westonruter
Below is an example;
Post: https://thebrag.com/tldr-week-cinema-bad-cop-bad-cop/
AMP version: https://thebrag.com/tldr-week-cinema-bad-cop-bad-cop/amp/

img src="https://i.imgur.com/d1NBb20.gif" alt="" width="425" height="238.85" tag has been converted to amp-anim src="https://i.imgur.com/d1NBb20.gif" alt="" width="425" height="" sizes="(min-width: 425px) 425px, 100vw" class="amp-wp-enforced-sizes"

Google SC is reporting this as "Invalid value for attribute in layout 'height' in tag 'amp-anim'". Is there any quick solution or patch?

Thanks.

sach-patel commented Mar 28, 2018

@westonruter
Below is an example;
Post: https://thebrag.com/tldr-week-cinema-bad-cop-bad-cop/
AMP version: https://thebrag.com/tldr-week-cinema-bad-cop-bad-cop/amp/

img src="https://i.imgur.com/d1NBb20.gif" alt="" width="425" height="238.85" tag has been converted to amp-anim src="https://i.imgur.com/d1NBb20.gif" alt="" width="425" height="" sizes="(min-width: 425px) 425px, 100vw" class="amp-wp-enforced-sizes"

Google SC is reporting this as "Invalid value for attribute in layout 'height' in tag 'amp-anim'". Is there any quick solution or patch?

Thanks.

@westonruter

This comment has been minimized.

Show comment
Hide comment
@westonruter

westonruter Apr 2, 2018

Collaborator

@sach-patel the fix is coming in the 0.7 version of the plugin. I suggest testing 0.7-beta2 which should be out this week.

Collaborator

westonruter commented Apr 2, 2018

@sach-patel the fix is coming in the 0.7 version of the plugin. I suggest testing 0.7-beta2 which should be out this week.

// Provide default dimensions for images whose dimensions we couldn't fetch.
if ( false !== $dimensions ) {
$node->setAttribute( 'width', $dimensions['width'] );
$node->setAttribute( 'height', $dimensions['height'] );

This comment has been minimized.

@westonruter

westonruter May 4, 2018

Collaborator

These should not have been removed. See #1117.

@westonruter

westonruter May 4, 2018

Collaborator

These should not have been removed. See #1117.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment