Using Drupal 9.4. The Media File system is set to Private The Drupal default media type Image is set to private. It now contains hundreds of images. We want to switch only this media type from private to public. We want to keep PDF files private, these are in the Drupal default media type Document.
My process is this. Copy all the images from the private folder over to the public folder, keeping the original sub-directories. Then delete the images from the private folder. Go to > Media Types > Image > Manage fields > Edit image > Field settings - Switch from private to public. Note* It says. There is data for this field in the database. The field settings can no longer be changed. But it accepts the change to public.
Next, update the url in the file managed SQL table, so the url path is public instead of private. This command came from this post. And works great. It updates every file including pdf, word and jpegs. But I just want to update jpeg, png, gif. Can it be modified to only effect a certain filemime? I can run it 1 at a time for each filemime.
UPDATE file_managed SET uri = REPLACE(uri, 'private://', 'public://') where instr(uri, 'private') > 0;
In the SQL File Managed table there is a column filemime. The example data in this is: image/jpeg image/gif application/pdf Would it be something like this to target the filemime
WHERE filemime = 'image/jpeg';