Jump to content

Move uploaded images or files from one page to another


Webrocker
 Share

Recommended Posts

Hi,

Imagine this setup:  a "images" field (or a "file" field) in the page's basic template, lets call it "files" for the rest of this post.
In the front-end, a list (or a gallery) is rendered, when "files" are uploaded and saved at that page.

The editor created a page "documents", uploaded several files over the course of weeks, and later decides, that it would be smarter to make subpages for some sort of grouping of said files.

Is there a way for the backend editor to "move" files from page A file-field to page B file-field in the backend without the need to re-upload them?
I know that this could easily be done via the API or even by moving the files from assets/files/1234/ to assets/files/5678/ and modifying the "page_id" in the field_file table.
But I thing this would be a nice addition to the editor's experience, if the already uploaded files could be transferred across pages, if the same fields are used.

I know that the editor could link from the new page's text/body to the files "living" at the old page, but in my setting, where the front-end tries to look for files directly at the page level to spit out a list, this isn't so great.

I also know that this is maybe a higher order design "problem" -- if I'd expect a greater flexibility regarding images or files, maybe I should work with dedicated "file"-template/pages, and use page-fields for the then file references. It is just that I came across this small innocent question from a user of a very small uncomplicated site, where the above happened. No big deal, we got it sorted, but it made me think. ?

cheers,
Tom

Link to comment
Share on other sites

Short reply: There's no built-in way to move files around like that. However, you could clone the page as many times as you need, and then go back in and delete everything you don't need anymore.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

18 hours ago, Webrocker said:

I know that this could easily be done via the API

Anything that can be done with the API can be turned into an executable action with @adrian's Admin Actions module. And you can make an action available to non-superusers too.

There's a built-in "Copy Field Content to Other Page" action that you can use as a starting point. This action doesn't work out-of-the-box for Files or Images fields but it wouldn't be difficult to get it working, especially now that you can use Pagefiles::add() with a Pagefile object so that descriptions and tags get copied over automatically. And if you update the action maybe submit a pull request to the module repo with your changes...?

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...