Jump to content

Image field - select image from another page


cb2004

Recommended Posts

  • 2 weeks later...

I'll doubt this will find it's way into the core as extension of FieldtypeImage. A images field is a field to store images, not to choose them. Fields are first and foremost there to hold data. If you want to choose images then you'd need some kind of reference field, that just stores references to images, then it doesn't matter if they are from the current page or from another one. 

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

what would be a usecase for this?

The website of a photography club.

Members of the club each have a gallery, a page that consists of a number of fields including an image field.

Home page editors would like to select images, which have previously been uploaded by members to their (the member's) galleries, for inclusion on the site's home page. A 'best of' selection if you like.

Link to comment
Share on other sites

That's a usecase where the one-page-per-image is certainly useful as most images will have further information like dates, technical infos and so on. This would let you use simple page fields.

E.g. on my imagined home page template there is a page select field that displays a list of all 'image' pages?

https://processwire.com/talk/topic/11070-one-image-per-page-making-it-easy-for-editors/

https://processwire.com/talk/topic/11040-visual-page-selector-commercial-page-picker-module-for-processwire/

By the way, it is true that there can be a case where information in addition to 'description' is desired, but it isn't the only case. For example, the members of such a club may not be concerned with anything other than the visual information. In that case an image field is suffiecient.

From the point of view of the user that approach is straightforward and other modules can extend it e.g. http://modules.processwire.com/modules/image-extra/

Link to comment
Share on other sites

  • 1 month later...

+1 for this. As LostKobrakai pointed out, this wouldn't be an extension of FieldTypeImage. Maybe just an InputField like that used for Image, but storing a reference similar to a Page fieldtype.

One case where this would be very useful is for selecting the image that will be used in the og:image meta tag. You want a single-image inputfield that selects from the images that have been already loaded to Image fields on the page.

I'd love a field that has a setting for which page(s) images would be selectable from. So you could fix a page or pages (e.g. current page) in the settings, or allow the selection of a page from the inputfield (like what is possible in an RTE field).

I think a field like this would be a great asset in PW - if there are use cases for selecting images from external Image fields within an RTE field then there are bound to be use cases for selecting them in a dedicated "image reference" field.

  • Like 3
Link to comment
Share on other sites

  • 2 months later...

Seems like this would be a nice addition. I have also just come up with a need for this for files as well. The file already exists on another page but I can only select the file from the RTE (but I want to add some styling and a font awesome icon), but I want this to be selectable from a field.

Link to comment
Share on other sites

Is it really that hard to create a Image/File reference field? The modal window even exists in the RTE dialog.

The thing is: What it needs is a field, that returns a image OBJECT, not markup like RTE or all other plugins like ImageTags do. So that you can use all the nice frontend methods like cropping, caching, compressing etc. The only ways so far are:

a) Use Image fields.

You create doubled image uploads and have to redo all operations (cropping..) on the uploads

b) Use RTE.

You get the image only as markup - Well you can parse it, get the id, request the databse :(

You need "expensive" fields in your backend, instead of a ID-entry-field

You can not prevent users from editing more stuff (text, more images..) into your input

Use cases for Image-References:

- Group Images by topic to achieve clean backend structures

- Less place in complex input scenarios

- To avoid double uploads: Place ImageFields outside Repeaters, ImageReferences inside

- To avoid double uploads: Place ImageFields outside PageTableExtended, ImageReferences inside

- To avoid double uploads: Place reused page elements (like brand elements, trust symbols) in a global (maybe write proteced) folder

- To avoid double uploads:Reuse Images in complex multi picture content blocks like <picture>-Elements

- Use Image-Files with different meta infos, captions etc. without double uploading

Nice to have feature extensions:

- optional preview picture

- optional additional fields (like in ImageExtra)

Link to comment
Share on other sites

More use cases for pages-as-image-picker:

News sites - a generic article with no photos gets a generic accompanying image, e.g. an EU flag for EU stories, a police car for police stories, etc. There can easily be hundreds of such stories, and dozens of such photos. It's not very elegant to make users upload the same photo 200 times.

Donated images - It's common for nonprofits to be donated use of photos for x years, but they must ensure the photos are properly described and credited every time they're used, and are replaced when the contract is up. This is pretty much impossible without central image management, especially with multiple users.

  • Like 1
Link to comment
Share on other sites

i think some of the usecases can be solved by using normal pages and using https://processwire.com/talk/topic/11040-visual-page-selector-commercial-page-picker-module-for-processwire/ for selecting them on other pages

I think you're right, but it's more a case of "will be solved" rather than "can be solved" because the module isn't available yet. Eagerly looking forward... :)

  • Like 3
Link to comment
Share on other sites

VPS does look great, but it is a page selector. My idea was an image/file selector outside of the RTE. The functionality to add images/files from other pages is an easy process and available in the RTE, but not in an image/file field.

Link to comment
Share on other sites

It's true, that the functionality is already part of the RTE workflow, but it's also deeply integrated into the CKEditor plugin / cropping and probably hardly usable for creating a new inputfield with it. If you want to take a look: /wire/modules/Process/ProcessPageEditImageSelect/. It's not that quite copy&paste job like it sounds like.

Link to comment
Share on other sites

I tried to build this one on friday. I used a onClick event on a input field, a part of the RTE Javascript where I altered the return value (img markup) into the PageID/Src out of the data-idname-attribute. It worked very well as a proof of concept. I will try to get a better version, where it returns a json of significant Image properties.

There are some design decisions to make:

- use cropping, resizing etc.?

- create a cached image version on these actions or get only the editing data to do all operations live in the use context?

and so on. But it's possible. One thing to mention: What is the license of the CKE modul pwimage

Link to comment
Share on other sites

dropped a first prototype onto github some minutes ago. very early stage, developed and barely tested under PW 3.0.9. Reuses some stylesheets from CKEditor, so be sure you have installed that as well, if you want to test it.

https://github.com/nikosch/ProcessWireImageLink

[edit]

not sure, if this works in other versions of PW and how it behaves with additional image processors. But the code is no rocket science, so the chances are not too bad :)

  • Like 7
Link to comment
Share on other sites

 Servus bernhard, thank you for your attention. After a long office day I will better try this on weekend :rolleyes: *). Fixed some stuff for the moment, especially dependencies from other modules (CKE).

*) besides I have to clean up a messy PW test installation first :)

  • Like 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
  • Recently Browsing   0 members

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