• Resolved niftyjohn

    (@niftyjohn)


    I’m using wp_get_attachment_image() and wp_get_attachment_image_src() methods inside shortcodes to make my sites much more modular. However, the plugin is not switching to the amp version so no images are populating. This not a thing for the plugin or just an oversight? Thanks!

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • @niftyjohn I can see some validation errors but not related to images, they are related to iFrames, with references to the Gravity Forms plugin. This could be similar to this previous post, which contains a potential fix.

    It might also be worth looking at this Github issue.

    Can you check if the errors appear with any of your Gravity Forms disabled? You might also want to disable any other AMP plugin if you have them active.

    Thread Starter niftyjohn

    (@niftyjohn)

    The images aren’t loading on the frontend at all and are stripped out. Look at divorce-matters.com to see the live version of how it should be looking. Here’s the backend error within the plugin for all images on the page: https://divorcematters.staging.wpengine.com/wp-content/uploads/2019/08/Screen-Shot-2019-08-29-at-10.25.09-AM.jpg

    I haven’t gotten to the gforms issue yet but it could be because I have gforms nested inside another shortcode?

    Thread Starter niftyjohn

    (@niftyjohn)

    Ok, I read through the gforms resources. Takeaways: you guys won’t be directly support gforms, there might be methods to fixing them but it’ll be through custom coding via gforms methods.

    That’s great. New question that is related to both. Is there a hook or global var that I can use to run code only on AMP? I haven’t discovered one yet and I didn’t notice a direct one in the documentation.

    This is useful for me so that I can custom fix my img tags and gforms without compromising the desktop experience, directly or indirectly. Thanks!

    Thread Starter niftyjohn

    (@niftyjohn)

    I think I just found it on https://xwp.github.io/amp-wp/. This the intended method if it’s a AMP page? is_amp_endpoint()

    If it is, any assistance with the image problem would be great! Thanks!

    @niftyjohn You’ll find more on the is_amp_endpoint on the plugin website. But yes, it can be used for AMP URLs only.

    In relation to your image issue I can see the img markup only in your non AMP. Did you add some functions or a plugin which might be impacting this? Maybe try activate another theme and deactivate any image optimisation plugins in use before checking again.

    Thread Starter niftyjohn

    (@niftyjohn)

    So, the theme I’m using is a heavily modified version of TwentyNineteen. I have shortcodes for sections that get_template_part() where the rest of the code is stored in basically raw HTML & PHP. So, in these files I’m simply using doing this:

    <?= wp_get_attachment_image(36, ‘full’, false, array(‘alt’ => ’10 best client satisfaction, American Institute of Family Law Attorney’)); ?>

    I have that directly in my header.php file and it’s not working for the logo next to the nav. I don’t think this is isolated to the shortcodes.


    Good thought; I do have Optimole but it hasn’t been active on the staging site at all.

    @niftyjohn I don’t think the issue is just related to your images, the content inside your header tags are also not visible on your AMP URLs.

    How are you using is_amp_endpoint() to restrict any content on AMP, can you share any functions which may be impacting these issues?

    Thread Starter niftyjohn

    (@niftyjohn)

    I’m actually not using the method at all in the theme right now. I simply added the plugin and here are my plugin settings.

    I’m trying to use as little custom code as possible for AMP because I have a few hundred to roll this out to once I get it nailed down.

    I can see some references to lazy loading on some of your images, a lazyload class. Are you using any additional plugin? If you can share your site health information I can see if I notice anything.

    Thread Starter niftyjohn

    (@niftyjohn)

    Woah! Thank you for noticing that! Our team built a custom lazy loader that’s much more stable than seemingly anything else out there. I needed to turn off that function if it was an AMP page. Thank you!

    Great news, and nice work on the site, in transitional too. Feel free to leave the plugin a review if you find you are benefiting from it.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Plugin not converting wp_get_attachment_image()’ is closed to new replies.