Jump to content
Webrocker

Move uploaded images or files from one page to another

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

As @Robin S mentioned, I'd be happy to accept a PR for this enhancement!

  • Like 1

Share this post


Link to post
Share on other sites

Hi Robin + Adrian, 

thank you, will have a look and if I come up with something, will PR. 

cheers,

Tom

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...