.amp-carousel-slide > .i-amphtml-replaced-content {
-o-object-fit: contain;
object-fit: contain;
}
I tried different variations of the CSS selectors but none of them seem to work such as:
amp-img.amp-carousel-slide img {
-o-object-fit: cover;
object-fit: cover;
}
Not sure why it is not working.
]]>What changes do I have to make in the template so that it will get detected as AMP list?
]]>I am trying to implement an amp-carousel on my site, but I am having issues with the carousel requiring at least 3 slides in order for the slide animations to work.
I haven’t been able to find a solution to this issue, but I noticed that the script imported by the AMP plugin is the 0.1 version of amp-carousel.
<script src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js" async="" custom-element="amp-carousel"></script>
Is there a specific reason why the old version of the component is used instead of the newer version? (and is there a chance that my slide animation problem might be fixed by updating the component?)
I’m having an odd issue with trying to replace a slick slider with an amp-carousel. The template is called the html is echoed but when the final page is rendered amp appears to have stripped out the html. I copied the html from within the template and pasted it into where it should be on the page and it appears to work (well formatting is some way off but probably missing the css for it) if you look at the non amp version of the page i linked above it will show the slider just above the footer. So here’s what i have code wise. First in functions i added a test for amp
function example_is_amp() {
return function_exists( 'is_amp_endpoint' ) && is_amp_endpoint();
}
I then added a test for amp and enqueued the amp-carousel script
if (example_is_amp()) {
wp_enqueue_style( 'style-css', $styleSheetDir . '/amp-style.css', false, '');
wp_enqueue_script('amp-carousel', 'https://cdn.ampproject.org/v0/amp-carousel-0.2.js', '', '', false);
} else {
//animate.css
wp_enqueue_style('animate', $styleSheetDir . '/css/animate.css', '', '');
wp_enqueue_style('style-css', $styleSheetDir . '/style.css', false, '');
}
so far so good and the amp-carousel script is loaded when we have an amp page.
I then modified the template which renders the slick slider again using the is_amp_example() conditional the code builds a $html string and on completion it echoes it. for simplicity I’ll show the rendered content in $html when it is echoed. This is as follows:
<div class="latest__slider small-12 large-centered columns">
<div class="slider__heading hide-for-medium-down large-3 columns">
<h2>Our Work</h2>
<ul class="slider__nav latest-projects-slider">
<li class="slider__nav__number"><span>01</span></li>
<li class="slider__nav__number"><span>02</span></li>
<li class="slider__nav__number"><span>03</span></li>
<li class="slider__nav__number"><span>04</span></li>
<li class="slider__nav__number"><span>05</span></li>
<li class="slider__nav__number"><span>06</span></li>
</ul>
</div>
</div>
<div class="slider__slides small-12 large-9 columns">
<h2 class="show-for-medium-down text-center">Our Work</h2>
<div class="portfolio__slider__wrapper">
<div class="portfolio__slider__track latest-projects-slider">
<amp-carousel width="235" height="134" layout="responsive" type="slides" controls>
<amp-img src="https://www.urbanlandscapedesign.co.uk/wp-content/uploads/2016/08/fed-care-home-slider-1.jpg" alt="Heathlands Care Home" width="214" height="120" alt="<p>Directly with the client, we constructed and installed a beach themed garden, suitable for Dementia patients</p>"></amp-img>
<amp-img src="https://www.urbanlandscapedesign.co.uk/wp-content/uploads/2017/03/large-private-garden-slider.jpg" alt="Large Private Garden" width="214" height="120" alt="<p>We have been working with this client for a number of years on various projects within this garden including outdoor kitchen, hot tub, Victorian kitchen garden and woodland area</p>"></amp-img>
<amp-img src="htts://www.urbanlandscapedesign.co.uk/wp-content/uploads/2017/03/hewitt-chester.jpg" alt="Contemporary Garden Chester" width="214" height="120" alt="<p>A cool contemporary project on a new build property in Chester.</p>"></amp-img>
<amp-img src="https://www.urbanlandscapedesign.co.uk/wp-content/uploads/2016/08/hoole.jpg" alt="Contemporary Courtyard Chester" width="214" height="120" alt="<p>In this small courtyard development in Hoole, we created a cool split level space for the client who wanted a modern feel.</p>"></amp-img>
<amp-img src="https://www.urbanlandscapedesign.co.uk/wp-content/uploads/2017/03/outdoor-kitchen-urban-office-slider.jpg" alt="Urban Landscapes HQ" width="214" height="120" alt=""></amp-img>
<amp-img src="https://www.urbanlandscapedesign.co.uk/wp-content/uploads/2017/03/outdoor-living-slider.jpg" alt="Urban RHS Tatton" width="214" height="120" alt=""></amp-img>
</amp-carousel>
</div>
</div>
</div>
If this is pasted into the rendered page (within the <div class=”latest__background”> div) the carousel appears and works (although styling is messed up and in a tablet/desktop it should show more than one image (as can be seen on the non amp page) I’ll fix styles etc once the underlying concept is working.
So why is the html being removed from the rendered page. I use exactly the same template and process to get the content (ie build the html string and echo it) but content is not removed on non amp page?
Is there a way i can make this work? is there a direct way to swap for slick-slide or is amp-carousel the best/only option? from what i see it should cover our usage case(s)
I’ve tried using img instead of amp-img and with and without responsive=”responsive”. I also tried the version 0.2 of amp-carousel but again no content.
At a loss with it now.
thanks
Craig
]]><amp-carousel width=”400″ height=”300″ layout=”responsive” type=”slides” autoplay delay=”7000″>
<amp-img src=”https://autoxtend.com/wp-content/uploads/2018/12/WelcomeDec2018_555PX.jpg” width=”400″ height=”300″ layout=”responsive” alt=”Meet Our Team”></amp-img>
<amp-img src=”https://autoxtend.com/wp-content/uploads/2018/05/Brakes555PX.jpg” width=”400″ height=”300″ layout=”responsive” alt=”Quality Brake Parts”></amp-img>
<amp-img src=”https://autoxtend.com/wp-content/uploads/2018/05/001Jasper555PX.jpg” width=”400″ height=”300″ layout=”responsive” alt=”We sell and install Jasper Engines”></amp-img>
<amp-img src=”https://autoxtend.com/wp-content/uploads/2018/06/6MonthCash555PX.jpg” width=”400″ height=”300″ layout=”responsive” alt=”Interest deferred”></amp-img>
<amp-img src=”https://autoxtend.com/wp-content/uploads/2018/05/8diesel555PX.jpg” width=”400″ height=”300″ layout=”responsive” alt=”We repair diesel.”></amp-img>M
<amp-img src=”https://autoxtend.com/wp-content/uploads/2018/05/CooperYouFound555PX.jpg” width=”400″ height=”300″ layout=”responsive” alt=”Youve found your tire store. We sell Cooper Tires.”></amp-img>
<amp-img src=”https://autoxtend.com/wp-content/uploads/2018/08/7SureCritic555PX.jpg” width=”400″ height=”300″ layout=”responsive” alt=”Read customer reviews at Sure Critic.”></amp-img>
</amp-carousel>
Thanks,
Nicola
]]>I wanted to create an AMP version of my landing page, so first I installed https://www.ads-software.com/plugins/accelerated-mobile-pages/. But the homepage looked bleak, so I studied AMP advanced features here: https://ampbyexample.com/advanced/image_galleries_with_amp-carousel/
and wanted to add them to my page.
1. openned up the editor, copied and pasted the carousel AMP code
2. replaced the image links with my ones, replaced the captions
3. switched from HTML editor to visual editor
4. switched back
5. only what seems to be recognized non AMP html remained:
<div class="slide">
<div class="caption">Fashion E-shop with custom design</div>
</div>
<div class="slide">
<div class="caption">Sleek design to present property management services. One page design.</div>
</div>
<div class="slide">
<div class="caption">Blog with extended features - user marketplace, post your own articles, custom ads management and nice article layout.</div>
This feels like a bug – wordpress editor hasn’t caught up with latest AMP development?
thanks,
Lukas