Skip to content

Enhancement - Global _wp_attached_file protocol option #1

@devfreddy

Description

@devfreddy

I see there is a way on a per upload basis to set the protocol that is stored with the image url in _wp_attached_file.

Unfortunately this is per upload, and it defaults to HTTP.

I've written a little snippet to jump in on update_attached_file and modify the file url, so that even if user's don't make the HTTPS selection, it changes it anyways.

add_action( 'update_attached_file', function ($file) {
    if(stripos($file, 'http://res.cloudinary.com') !== FALSE){
        $file = str_replace('http://res.cloudinary.com', 'https://res.cloudinary.com', $file);
    }
    return $file;
});

It wouldn't surprise me if there is a need for some organizations to want to define the Protocol on each upload, but I also think it would be really nice to have an 'on every upload' option.

For those of us who would prefer a global setting for this, I have a proposition.

Add a Protocol setting, on the Wordpress side, under the main Cloudinary Settings screen

Image Protocol

  1. Define on each upload
  2. Always HTTPS
  3. Always HTTP

Based on these settings, we can either leave the functionality as it is, or optionally jump in and toggle it, using something similar to the above, regardless of what user's select when uploading.

After we hammer out any thoughts/details, I'd be happy to work on this and contribute it back.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions