Jump to content

FieldtypeImageFromPage pick an image from various sources


gebeer
 Share

Recommended Posts

I have made good progress and have a working version now, that allows to pick an image from a predefined page (and optionally its children), a folder inside site/templates or the page that is being edited.

The version is available in the branch 'allinone' on github
Install from URL https://github.com/gebeer/FieldtypeImageFromPage/archive/allinone.zip
If you find the time, please do some testing and report your findings. Thank you. If you test, please uninstall previous versions and install this one.
EDIT: Also uninstall InputfieldImagePicker if you happened to install it.
My code does not cater fully for DB update, yet. And since I switched field value storage to json, atm this has to be installed from scratch.

The module is still on that repository. But eventually I will publish it on the ImagePicker repository when I feel it is ready.

One thing I still have to solve: ATM the field returns 2 different objects for rendering in templates, depending on where the image comes from. If it comes from a page, you will get a Pageimage object. If it comes from a folder inside site/templates, you will get a custom ImagePickerFile object. The latter one cannot be manipulated (resizing/cropping) like a Pageimage but has some similar properties.
I still have to find a way how to turn images from a folder that is not connected to a page into Pagimage objects. This is quite tricky. I wonder if anyone who is reading this has evr tried to accomplish something similar.
I really always want to provide a Pageimage object, no matter where the real image file lives so that it can be manipulated. Still scratching my head on that but hope I will find a solution.

  • Like 3
Link to comment
Share on other sites

Really short on time, but wanted to take a quick look. So far looks really great - thank you!

I noticed this error - only occurs if the child page doesn't have images available.

image.png.c2c6e93be7b599aa5a3c65c11ed7fd51.png

Also, I am wondering about the radio buttons as a way to choose the fields that images can come from. I would have thought checkboxes were better to allow for multiple fields. This may be for multiple fields on the one page/template, but I can see it also being useful for different pages with different templates that have different image fields. Does that make sense?

 

  • Like 1
Link to comment
Share on other sites

21 minutes ago, adrian said:

I noticed this error - only occurs if the child page doesn't have images available.

Thanks for reporting.

21 minutes ago, adrian said:

Also, I am wondering about the radio buttons as a way to choose the fields that images can come from. I would have thought checkboxes were better to allow for multiple fields.

I was thinking about that one, too. But then I decided to allow only one images field because it might confuse users. But then, if I allowed multiple fields, the user could upload to any images field and have them available for the picker. Think, finally I will add this.

  • Like 1
Link to comment
Share on other sites

31 minutes ago, gebeer said:

 

regarding that error. Do you also have my module ImagePicker installed on that site?

Yeah, I did. I just uninstalled it and that error is now gone, but I am now seeing: 
image.png.79b5d789777719cecb0d72ec0474fb0c.png

and having real problems getting rid of it.

Link to comment
Share on other sites

3 minutes ago, adrian said:

Yeah, I did. I just uninstalled it and that error is now gone, but I am now seeing: 
image.png.79b5d789777719cecb0d72ec0474fb0c.png

and having real problems getting rid of it.

Sorry for that one. InputfieldImagePicker did not manipulate any other image fields. Was your field 'image' created from InputfieldImagePicker? If so, you need to remove it and the error should be gone

Link to comment
Share on other sites

3 minutes ago, adrian said:

It wasn't created that way - just a regular image field. Even after deleting it I am still seeing the error - will have to dive deeper to see where it's originating.

Really sorry for the trouble. Maybe caching issue? The 2 modules were never supposed to be installed alongside each other and I didn't take that into account since it is planned to replace the 'old' ImagePicker module with this one. Added a warning to my post above so others won't fall into that pit.

  • Like 1
Link to comment
Share on other sites

Not your fault at all - took me a while, but turns out it was my definition of a field in SettingsFactory that was causing the problem ?

All sorted now and the new version works great for Settings Factory as well - really cool - I especially love the ability to upload directly via that field and it automatically reloads the available images after closing the modal. 

Link to comment
Share on other sites

3 minutes ago, adrian said:

All sorted now

Glad you sorted it!

1 minute ago, adrian said:

One small thing - note the wrapping of the filename which I think should be fixed

This is on purpose. Otherwise the filename would overflow the background area, especially on not so wide previews. Doesn't look very nice as it is, I know. In the CSS I had  hyphens: auto; before but that would break the filename to the next line too soon. So I decided to go for word-wrap: break-word; instead.

  • Like 1
Link to comment
Share on other sites

One minor thing: when I choose to use "from-folder" as image-source, then it is not possible to upload new images into the folder within ImagePicker. Is this planned behavior, or can it be solved? Thanks.

billede
This upload-icon is missing, when picking image from folder.

Link to comment
Share on other sites

3 hours ago, eydun said:

I finally tested the branch version, and it works great!

Thank you for testing!

2 hours ago, eydun said:

One minor thing: when I choose to use "from-folder" as image-source, then it is not possible to upload new images into the folder within ImagePicker. Is this planned behavior, or can it be solved? Thanks.

This is intended behaviour at the moment. But I am planning on incorporating an upload widget for the folder images, too. For uploading the page images the module uses the standard PW page edit feature. But since folder images are not linked to a page (at least not yet in the current version), I need to use a different solution here. I like https://uppy.io/ a lot and think I will implement it for managing images in the folder.

I have merged all the features of this module into my ImagePicker module and will release a new version of that this week.

  • Like 2
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

×
×
  • Create New...