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

Block gallery styles erroneously get output as separate style from amp-custom in Classic mode #1780

Closed
westonruter opened this issue Dec 26, 2018 · 12 comments

Comments

@westonruter
Copy link
Member

Reported in https://wordpress.org/support/topic/amp-custom-is-missing-in-the-class-amp-gallery-embed-php/

On a site with Classic mode, the template is currently generating the following invalid markup in the head when a gallery is used:

<style amp-custom>
...
</style>
<style>
	.wp-block-gallery.is-cropped .blocks-gallery-item amp-img > img {
		object-fit: cover;
	}
</style>

This seems to be due to the use of wp_print_styles action introduced in #1627 via 6b7d305.

@westonruter westonruter added the Bug Something isn't working label Dec 26, 2018
@westonruter westonruter added this to the v 1.0.2 milestone Dec 26, 2018
@westonruter westonruter removed this from the v 1.0.2 milestone Jan 15, 2019
@westonruter
Copy link
Member Author

This seems to be a plugin compatibility problem with NextGEN Gallery. In particular, there is a conflict between how that plugin (for some reason) does output buffering in its resource manger component. Here is a workaround compatibility plugin: https://gist.github.com/westonruter/99b1ca0d593f44888401a396d991e3a6

See also https://wordpress.org/support/topic/amp-custom-is-missing-in-the-class-amp-gallery-embed-php/#post-11092401

@westonruter westonruter removed the Bug Something isn't working label Jan 15, 2019
@jackmcconnell
Copy link

I am also experiencing this but am not using NextGen gallery. I'm using a custom theme and have disabled all functions to try and prevent the issue from occurring but it still appears. This leads me to believe that a core WordPress function relating to images that is used by the theme may be causing the issue. Additionally, I believe better handling of when this style is output on the page should be added as, whilst using the latest version of WordPress, the whole site is using the Classic Editor plugin and as this related to a Gallery Block in the Block/Gutenberg editor, it shouldn't be being added to the page at all.

@westonruter
Copy link
Member Author

I believe this issue will be made obsolete by #2202 since the entire Reader mode template will be sent through the AMP processor.

Here's a recent development build you can test to confirm: amp.zip (1.5.0-alpha-20200107T191925Z-833fbf594)

@jackmcconnell
Copy link

Thanks @westonruter. Have installed and am testing but nothing in between the if (have_posts()) : while (have_posts()) : the_post(); and endwhile; else : endif; is being rendered on the page. Is this expected?

@westonruter
Copy link
Member Author

No, that is not expected.

@jackmcconnell
Copy link

@westonruter I appreciate this probably isn't the place for this but when using any custom theme i've tried and using a custom AMP template, nothing is rendered between the if (have_posts()) : while (have_posts()) : the_post(); and endwhile; else : endif; when using Reader mode and only Website and Posts are checked in AMP > General. Reverting back to v1.4.2 renders everything as expected.

@jackmcconnell
Copy link

Ok, it seems that using the_content(); outside of the loop when on an AMP template is the fix for now. The loop seems to fail completely in this scenario. Will investigate more if I have the time.

@westonruter
Copy link
Member Author

What template mode are you using? Standard, Transitional, or Reader?

So you have AMP-specific templates in your theme (in an amp/ subdirectory)?

@jackmcconnell
Copy link

Reader Mode. I've using the amp_post_template_file filter to set my own template for posts (a modified single.php file).

@westonruter
Copy link
Member Author

Can you share the original single.php file before you made changes to it?

@jackmcconnell
Copy link

Sure. See attached.
single.txt

@westonruter
Copy link
Member Author

@jackmcconnell Thanks very much. You identified a bug. I've opened a fix in #4185. In the future you'll be able to use The Loop as normal. Here's a new build to test: #4185 (comment).

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

No branches or pull requests

2 participants