1

On a Drupal 7 installation I have an image gallery (set up with the media gallery module). I set the upload destination to private to protect those images for anonymous users. Unfortunately it turned out, that the performance of private images is that poor, that the gallery became quit unusable.

So I decided to switch the destination to public for the node type. But as there already exist nodes of the mentioned type (I assume that my be the reason), the options of the node type's filed, where to set the destination is greyed out:

enter image description here

Is there any way to change the destination for existing nodes?

2

You could accomplish this by moving the files out of the private directory and into the public directory (make sure the paths stay the same!). Then you would need to update the 'file_managed' table. The 'uri' table will list the files as either private or public. The mySQL would be similar to:

UPDATE file_managed SET uri = REPLACE(uri, 'private://', 'public://') where instr(uri, 'private') > 0;

NOTE Please make sure to test this on a dev site before doing in production.

| improve this answer | |
  • 1
    I'd rather make that REPLACE(uri, 'private://', 'public://'), having 'private' or 'public' elsewhere in a filename seems like it could happen often – Clive Sep 5 '14 at 19:27
  • 1
    Clive. Good call. I've updated my answer with your suggestion. – nmillin Sep 15 '14 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.