Jump to content

Move image between image fields


Robin S
 Share

Recommended Posts

Does anyone have any tips to share for moving an image from one image field to another on the same page in Page Edit?

I know it can be done with the API but it seems like there should be some way via the admin interface. Like adding an image to an image field by pasting a URL - is that possible via the core or a module?

Link to comment
Share on other sites

hmm, if you mean "moving" = moving image from image field A to B (and deleting the image from the source field A), I wouldn't know.

But if you mean "moving" = duplicating an image from image field A to B (leaving the source image in source field A), then simply right-clicking on the source image, copy the image URL, and adding it that way would work. (at least with a really quick test on Chrome / Win)

Not sure what the big picture in your scenario really is though...

  • Like 1
Link to comment
Share on other sites

1 minute ago, dragan said:

right-clicking on the source image, copy the image URL, and adding it that way would work

That would be fine, but how do you add an image to an image field via a URL? I feel like I've read something here in the forums about doing this but looking at the image field interface I can't see how it's possible. There is only the "Choose file" button for uploading an image and the drag-and-drop zone.

Link to comment
Share on other sites

the latest version also has an option to specify a field containing an image URL;

this way you can copy image urls off the web, paste into that field and it adds it to the images field (specified in the module config);

does the images field have a place to paste a URL - would that need to be added with a hook?

 

Link to comment
Share on other sites

right - got it; i haven't pushed the new features to the import module yet, as still testing, will push it soon, maybe next week; i will look at how to add an input to the image, but adding input field to inputfield is something i've never tried yet...

Link to comment
Share on other sites

14 hours ago, Robin S said:

but how do you add an image to an image field via a URL? I feel like I've read something here in the forums about doing this but looking at the image field interface I can't see how it's possible. There is only the "Choose file" button for uploading an image and the drag-and-drop zone.

Just click on "add new image", and paste the URL.

  • Like 1
Link to comment
Share on other sites

12 hours ago, dragan said:

Just click on "add new image", and paste the URL.

Thanks, I discovered this myself while I was experimenting yesterday, but it seems less than ideal for a couple of reasons.

1. When you do this, it seems that the image is first downloaded to your local disk, then uploaded to the site. This makes it unnecessarily slow for larger images or on slow connections.

2. The filename of the image is not preserved as per the original. On Windows Chrome at least, every filename gets "_1" appended to it.

But on the positive side this approach does allow for client-side resizing.

 

I had a go at a module that allows images to be added to a field via pasted URLs:

I had a few concerns about the approach because the page and image field are identified by values that could potentially be manipulated client-side. But I've included some checks that hopefully mitigate this.

Another niggle is that the API method $page->images_field->add() is surprisingly relaxed about what it will add to an images field. It doesn't seem to do any validation against the field settings or even disallow non-images from being added to an images field. So all the validation must be done independently (@Macrura, this might be something that affects your module too). I think I've accounted for most things, but if you guys will take a look and let me know if you spot any potential issues that would be great. :-)

Because the browser is not involved in the upload, no client-side resizing is possible but is done server-side instead (for max width/height settings).

 

  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...

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...