ACF for AMP – image not converting into amp-tags
-
I have an issue with images from google that “img” tag is not properly showed. It should be “amp-img”. So I’ve checked everything and there is one place where images are not in “amp-img” tag. This place is get_sub_field…
If I use repeater then images from TextEditor doesn’t display properly. Look at the image from my page in content and you will see.
Here are my ACF for AMP settings:
<?php ini_set("highlight.comment", "#abb2bf"); ini_set("highlight.default", "#61aeee"); ini_set("highlight.html", "#ffffff"); ini_set("highlight.keyword", "#c678dd"); ini_set("highlight.string", "#98c379"); ?> <div class="amp-wp-article-content content-acf"> <div class="amp-wp-content the_content"> <?php if (have_rows('content')) : while(have_rows('content')) : the_row(); ?> <?php if (get_row_layout() !== 'newsletter') : ?> <div class="amp-section-acf"> <?php if (get_row_layout() === 'text') : ?> <?= get_sub_field('text') ?> <?php elseif (get_row_layout() === 'image-wide' || get_row_layout() === 'image-narrow') : ?> <amp-img src="<?= wp_get_attachment_image_url(get_sub_field('image'), 'blog-post-details') ?>" alt="<?= get_sub_field('caption') ?>" width="<?= wp_get_attachment_metadata(get_sub_field('image'))['sizes']['blog-post-details']['width'] ?>" height="<?= wp_get_attachment_metadata(get_sub_field('image'))['sizes']['blog-post-details']['height'] ?>" layout="responsive"></amp-img> <?php if (get_sub_field('caption')) : ?> <p class="text-right"><i><?= get_sub_field('caption') ?></i></p> <?php endif; ?> <?php elseif (get_row_layout() === 'video') : ?> <?= get_sub_field('video') ?> <?php elseif (get_row_layout() === 'quote') : ?> <blockquote> <?= get_sub_field('quote_text') ?> <?php if (get_sub_field('quote_author')) : ?> <p class="text-right"><i><?= get_sub_field('quote_author') ?></i></p> <?php endif; ?> </blockquote> <?php elseif (get_row_layout() === 'code') : ?> <pre data-lang="<?= get_sub_field('language') ?>"><?php highlight_string(get_sub_field('code')) ?></pre> <?php elseif (get_row_layout() === 'infobox') : ?> <div class="infobox"><?= get_sub_field('text') ?></div> <?php elseif (get_row_layout() === 'cta-block') : ?> <div class="cta-box"> <?= get_sub_field('text') ?> <?php if ($button = get_sub_field('button')) : ?> <div class="cta-button"> <a href="<?= $button['url'] ?>" target="<?= $button['target'] ?>"> <?= $button['title']?> </a> </div> <?php endif; ?> </div> <?php endif; ?> </div> <?php endif; ?> <?php endwhile; endif; ?> </div> </div>
As you can see there is a line with:
get_sub_field('text')
and this one doesn’t provide to into my AMP view “amp-img” tag.Could you please help me with that?
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘ACF for AMP – image not converting into amp-tags’ is closed to new replies.