I have custom post

Hello,

I have custom post type “Product” with custom taxonomy “Product category”.

I use Advanced Custom Fields Pro plugin to extend my Product category with an uploaded image (so users may upload an image to each category).

Then, I have Smush Pro with enabled CDN. The CDN works for all images as expected. Except for the Product category images.

I tried following approaches to get the image URL.

First, ACF image field was set to return directly image’s URL.

Second, I change image’s return type to ID and then call wp_get_attachment_image_url($my_category_image_id,”size”:wink: to get the URL.

Last, I tried to set image return’s value to array.

In all cases, I got non-CDN URLs.

Other images uploaded via ACF’s custom fields work. Images are smushed. Cache cleared.

I tried to use smushed images from my media library as well as upload new image (auto smush is on).

I can’t figure out what is wrong. I tested all possible scenarios but these particular product categories’ images are simply not served via CDN.

Is there any WP filter to process URL of an image to get CDN’s URL if on?

Thank you in advance

  • Dimitris
    • Support Star

    Hello there Frantisek,

    hope you’re doing good today and thanks for reaching us! :slight_smile:

    In order to have a better look at your setup, could you please send me an email with some additional access details? As this is a public forum, you should send us your details through our safe contact form

    https://premium.wpmudev.org/contact/#i-have-a-different-question

    using this template:

    Subject: “Attn: Dimitris

    – WordPress admin (login URL/username/password)

    – (S)FTP credentials (host/username/password/path of site in question)

    – cPanel/Plesk/phpMyAdmin credentials (login URL/username/password)

    – your custom category template path in server

    – link back to this thread for reference

    – any other relevant urls

    Keep in mind the subject line as ensures that it gets assigned to me.

    Is there any WP filter to process URL of an image to get CDN’s URL if on?

    There’s no such filter as Smush CDN should be fetching all images and replacing them with the CDN URL.

    Warm regards,

    Dimitris

  • Dimitris
    • Support Star

    Hello there Frantisek,

    hope you’re doing well today and appreciate the info you shared via email. :slight_smile:

    After having a better look, I can see that you’re using these images as background images via some CSS code. Please keep in mind that Smush CDN can’t replace image links from CSS, either from external CSS files or inline CSS. In order to surpass this, you should either:

    – use the images within <img> tags instead, or

    – post the category images as normal images in a testing page, inspect that page to get the generated links from our CDN and hard-code these links in your template (not ideal, if you’re going to edit/add/remove these categories).

    Warm regards,

    Dimitris

  • Frantisek
    • WPMU DEV Initiate

    Hello Dimitris,

    thank you for your answer. Now I see how it works. My expectation was that images URLs are replaced via WordPress filter when a template is rendered. But as I see, it is not the case. Instead, Hummingbird takes the rendered page and replace values of “src” attribute, right?

    In that case, I will render hidden image tags and copy src value with JavaScript to my CSS.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.