• I’m trying to switch over from using imgix to cloudflare images.
    I’ve set up your plugin but it leads me to a couple of questions..

    1. The width of the image is generated in the URL can I turn this off and manually add a width? I’d like to use the url in a picture element with multiple source elements of different sizes.

    2. Can we make it use the image file name instead of the image ID?

    Thanks in advance for any advice!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Was just about to ask the same question! Instead of ‘w-9999’ can we set a default variant name? e.g. ‘/medium’

    Plugin Author Anton Vanyukov

    (@vanyukov)

    Hi @savvi and @jacklamond ,

    The flexible variants option, which the plugin uses, require a width parameter. Initially, I started developing this with the regular variants option, but it had a limit of 20 different sizes, which wasn’t working with some sites, so I had to switch to the flexible variants. I might add an option to switch between the two, I can see that Cloudflare bumped the number of variants to 100, which should cover all the use cases.

    Regarding the file name. If you enable the “Keep media library structure”, that should give you what you are looking for. If the images are already offloaded, you will need to bulk remove and bulk offload again to add the images with the proper meta values to Cloudflare.

    Best regards,
    Anton

    Thread Starter savvi

    (@savvi)

    Hi @vanyukov

    I’ve manually stripped the w para off of the end of the url with php and then add my custom ones on to the new URL:

    $url = explode(‘/’, $image[‘url’]);
    array_pop($url);
    $newUrl = implode(‘/’, $url);

    <img src=”<?php echo $newUrl; ?>/w=500,h=300,fit=cover” alt=”<?php echo esc_attr($image[‘alt’]); ?>” />

    This seems to work for now but yes would be great if could just turn this off with a setting.

    I’ll try the “keep library structure” settings tonight and see where I get.

    Thanks for the reply and suggestions!!

    @savvi could you please kindly write the instructions to implement this php code? I’m interested in giving it a shot! Thanks

    Plugin Author Anton Vanyukov

    (@vanyukov)

    @savvi,

    Maybe I misunderstood your question.. You still seem to be adding the w parameter, but just manually? Could you please provide more info on what you are trying to achieve?

    Best regards,
    Anton

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Manually Add Image Dimensions to URL’ is closed to new replies.