Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Anton Vanyukov

    (@vanyukov)

    Hi @peterkatoff,

    It doesn’t seem to be possible via Cloudflare Images directly. However, it could be possible to utilize workers, like you mentioned. I’ll see if there’s a workers API and if I could automate this from the plugin side. Will update this thread once I have more details.

    Best regards,
    Anton

    Thread Starter PeterKatoff

    (@peterkatoff)

    Thank you Anton.

    brutalistthemes

    (@brutalistthemes)

    Hi,

    I’m not sure if you’re still looking into this, but Cloudflare has added “Custom ID” ( https://developers.cloudflare.com/images/cloudflare-images/upload-images/custom-id ) so you can customise your file URL. I did some testing and it should be relatively easy to add to the plugin. I added this code to class-image.php above $data[‘metadata’] and it works pretty well, replacing the random ID with the wordpress file path.

    $data['id'] = get_post_meta($id, '_wp_attached_file', true);

    You may find a cleaner way to do this, with the file name instead of the file path, but as a temporary solution this works fine!

    Plugin Author Anton Vanyukov

    (@vanyukov)

    @brutalistthemes , thanks for the heads up. I’ve added a modified version of this to the upcoming release.

    Please be careful with the above code if you have multiple sites connected to Cloudflare Images. The ID must be unique, and if two images with the same name are uploaded to two sites, they will overwrite one another, and one site will serve an incorrect image.

    Best regards,
    Anton

    Plugin Author Anton Vanyukov

    (@vanyukov)

    I have pushed out the version with the custom ID functionality. I will mark this as resolved, but please don’t hesitate to create new threads or re-open this one, if any issues are discovered.

    Best regards,
    Anton

    how do you enable this functionality?

    Hi Anton
    If we use CF images with multiple sites is it now possible to use the unique image name?

    Plugin Author Anton Vanyukov

    (@vanyukov)

    @berkmh, to enable the functionality, please go to Media – Offload Settings and enable the “Keep media library structure” option. You will need to bulk unload and bulk offload all the images for the new structure to appear on the front-end.

    @nextodigital, yep, with the “Keep media library structure” option, the site URL will be appended to the image URL. For example, this is one of the images from my site: https://imagedelivery.net/maIo1hvgwNPOTgiq5vz5LA/vcore.au/2023/03/home-page-main.png/w=1024, as you can see the domain is appended and allows using same image names on different sites.

    Best regards,
    Anton

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Include Image Name in url’ is closed to new replies.