#2
Posted 13 April 2012 - 08:47 AM
#3
Posted 13 April 2012 - 09:39 AM
What you are referring to sounds like a type of page reference, and I think you could use the Page reference fieldtype to achieve this pretty easily.
Exactly. But not as a select for the page name (or the images url), more a visual approach by listing the images in a grid for example. Pretty much as Atti's (I think) inputfieldImageFlickr-thing. Thought about reusing this module but not by pulling flickr images but all images on the site (perhaps categorized by pages). I will take a look in the Page reference fieldtype.
But if you've got an instance where repeating the same image(s) is expected, then my preference is usually to code the template to pull them from a common page. For instance, in the default site profile, all the site's photos are on the homepage, and the rest of the site's pages pull them from there (at least for pages that don't already have photos uploaded to them). This is a technique I use on almost every site I build. Every page has an dedicated field for interface images. If no images are assigned to it, then it pulls from a common page, or the closest populated parent.
yeah, of course. This is the way I did it this in MODX. But it would be handy not only to pull standard values (parent or special page) and also not only define by page name but more visual by clicking on an image. Like in TinyMCE. But the approach in TinyMCE is different I guess because the result is the path to image which is then hardcoded in the content area. I would prefere the page (+image number) reference.
Thinking out loud:
- Fieldtype like image (drag&drop + select image from local disk) plus a "browse images from system" button which opens a popup/layer like in TinyMCE.
Perhaps not a good idea because the input result is different (images fieldtype store url + description I think, the browse option should store the reference to the original image with an optional possibility to overwrite the original description)
- So better approach I think: Different fieldtype which stores an array of references which can then be accessed like an ordinary image field by $page->myImages->url for example.
While typing this I still think a combination of the two fieldtypes would be nice but surely harder to implement
Okay, I just looked in the database. The image fieldtype doesn't story a unique ID, right? So a reference to a single image (not the url) could become difficult, right?
#4
Posted 13 April 2012 - 10:35 AM
Okay, I just looked in the database. The image fieldtype doesn't story a unique ID, right? So a reference to a single image (not the url) could become difficult, right?
That's correct. The primary key for an image is its page ID + sort order (if multiple images in the field). Once loaded in memory, images are indexed by their filename. Another image fieldtype could certainly add an ID property to a table easily.
#5
Posted 13 April 2012 - 01:21 PM
So what I think would be a possible approach:
A new module "inputFieldImageBrowsable" or something like that. This module extends the inputFieldImage module with addtional functionalities:
- adds a new column "imageID" or something to the standard field_image table
- adds a new button "browse site images" to the image field
- Configuration:
parent: the pages where to look for images (like a "media" node)
type: file extensions to look for
more things later (search by, more fields for each image, only landscape/portrait etc.) - button opens fancybox with grid/list view of the images (with url as "data", see below) found in [parent]
- possible to browse through pages via InputfieldPageListSelect
- selection of one or more images by clicking
- submit closes fancybox and shows the images
- The original extended fields (like description) get copied, but are overwritable
- images get new entry in table, but instead of url in field "data" only a reference to the id of the original image is stored (INT).
I think the same module could also handle ordinary files (also makes sense: Think of document management for manuals which are either added for a single page but can also be referenced on other pages).
Why all that? Well, pretty simple: With that approach you could easily change images and files site-wide without changing every single page only by changing the original file. And I think the possibility of mixing uploaded and referenced files in one field would be an exclusive feature compared to other systems
Sounds reasonable?
OT: Edit on Chrome/Mac messes something up in this forum (cannot use "full editor" either, but luckily "save" works ;-) )
#6
Posted 13 April 2012 - 05:06 PM
Also I know less than 1/1000th of a percent about this compared to Ryan; literally, so apologies if this is useless, but, it sounded as if this might be of some interest to you perhaps: https://github.com/N...oll/ManageFiles. I modified a copy of this slightly to:
# add permission 'managefiles' so this permission may be granted to user roles
# re-named columns and swapped around a little
# added 'description' so not just getting file name
I've not uploaded it to github yet as I am a total newb, but if you want a copy then just say.
#7
Posted 14 April 2012 - 05:58 AM
Let's take the example page of Ryan (the one with the skyscrapers). Here every skyscraper has one or more images which could be shown on other pages (architects) by creating many to many relations, which works great. But think of other kind of pages like press releases where you want to show only specific images which are already uploaded somewhere. At the moment you can either upload them again for that specific page or you know on which pages on which position they are and include them by hand with a selector. What I want to achieve is that you have the possibility to select single images from other pages by referencing them without duplicates. So if for example a skyscraper image is changed (perhaps of copyright problems) all images referencing this image are also changed.
With that the necessity of a media database is obsolete, because you can easily build it with pages. Or you don't build it and use all images/files site-wide as your media source.
#8
Posted 14 April 2012 - 11:27 AM
You likely know the following but just in case not, right now with Manage Files module installed I am able to (with a second tab open, so less than ideal) scroll to find the image I want in the Files page (that's installed by Manage Files module), see the page it's on and back on my first tab as I am editing copy in a TinyMCE textarea, click
the Image icon > images on page (drop down) > change the page from where I am to 'About us' > and select an image from there; then insert and re-size etc.
This keeps my data/images DRY and allows me to use images from any page on the page I'm editing.
This is not exactly what you were looking for I think, but just in case it helped at all I thought I'd note it.
#9
Posted 14 April 2012 - 12:08 PM
#11
Posted 14 April 2012 - 01:28 PM
One thing to consider is what removing the original image does for the references? Does those references get deleted too? Or does it copy the image for one reference and that will be the official home then?
#12
Posted 14 April 2012 - 01:30 PM
#13
Posted 16 April 2012 - 08:33 AM
#14
Posted 16 April 2012 - 09:11 AM
Some questions regarding this module:
- Is it possible to define a database schema of an inputfield "on the fly"? Say we have a configuration option for additional fields and I add another field ("title" for example) for one particular field (e.g. "myImage"). Does PW create this database column on first call or how can this be done?
- (also answer to Atti): I think if a referenced image/file is deleted the reference should also be deleted (with a once showed note). Reasonable?
- Are there some docs showing how to start such a project? I am a bit lost
I think first I should duplicate the image inputfield (+ fieldtype, right?) and try to create references first. Given that (hopefully) I would have to "hack" into the code where the page object is created, so a $image->title will become possible. How is this done usually?
Marc
#15
Posted 17 April 2012 - 08:42 AM
Is it possible to define a database schema of an inputfield "on the fly"? Say we have a configuration option for additional fields and I add another field ("title" for example) for one particular field (e.g. "myImage"). Does PW create this database column on first call or how can this be done?
Inputfields are just the input widget (no schema here), whereas Fieldtypes are the data format and storage (schema). For the most part, the schema of fieldtypes does not change from when it was created. The only exception is multi-language fieldtypes, which add new columns when a new language is added. For stuff that is more likely to change (like individual field settings) PW JSON encodes them in the 'fields' table. But this should only be used for things that don't need to be normalized or searchable.
Are there some docs showing how to start such a project? I am a bit lost
I think first I should duplicate the image inputfield (+ fieldtype, right?) and try to create references first. Given that (hopefully) I would have to "hack" into the code where the page object is created, so a $image->title will become possible. How is this done usually?
I think that the best starting point for a Fieldtype/Inputfield is the MapMarker fieldtype, which I made specifically for this purpose (as a well commented demonstration). I'm also here to assist in any way I can and guide you through it as you go.
Admittedly, I'm not yet sure how I'd approach a fieldtype that does what you are wanting it to do, so not yet in a good spot to identify the next step on that.
#16
Posted 17 April 2012 - 08:55 AM
Inputfields are just the input widget (no schema here), whereas Fieldtypes are the data format and storage (schema). For the most part, the schema of fieldtypes does not change from when it was created. The only exception is multi-language fieldtypes, which add new columns when a new language is added.
Ah, okay. Sorry for mixing this up.
Okay, since in the end the images/files should be searchable (as well as the fields added to it) I think these columns could be generated when a new field configuration is saved. But this is later on the roadmap ;-)For stuff that is more likely to change (like individual field settings) PW JSON encodes them in the 'fields' table. But this should only be used for things that don't need to be normalized or searchable.
I think that the best starting point for a Fieldtype/Inputfield is the MapMarker fieldtype, which I made specifically for this purpose (as a well commented demonstration). I'm also here to assist in any way I can and guide you through it as you go.
yes, this looks helpful. Also Atti's redirect module is a good starting point for module settings.
Admittedly, I'm not yet sure how I'd approach a fieldtype that does what you are wanting it to do, so not yet in a good spot to identify the next step on that.
But I think part of that is that I can't yet see how it would work to the user. A good place to start might be to mock it up. That would mean to show how it would look or work on the front end. These kind of mock-ups help the direction become more apparent.
I'll put something together ;-)
#17
Posted 17 April 2012 - 10:01 AM
#18
Posted 17 April 2012 - 03:13 PM
#19
Posted 18 April 2012 - 09:26 AM
The only way I can think of to bypass that is to actually maintain a blank placeholder image file as the actual reference. The placeholder filename would be in some format where it could be identified as a reference, perhaps something like: page[id]-[fieldname]-[filename].jpg. Using that method, the core could continue to do what it does. When it deletes the image, it deletes the reference file rather than the original image. But when outputFormatting is on, the module would know to convert the images in that specific format to the one that is referenced. Still a bit complicated, but just thinking out loud how something like this might be accomplished, and this might be a way.
#20
Posted 18 April 2012 - 09:43 AM
thanks for your thoughts.
I'm not sure this is something that can be implemented purely as a module, because the core assumes that files on a page are owned by the page. For instance, when you delete a page, it deletes all the files on the page. When you remove an image from a page, it deletes the image file when you save.
Well, as said above: When you remove an original, the references are gone, too. No problem with that. I would use a "media"-node with several pages under it, so it is clear that if I delete an item from the database it is gone. Customers also can be teached to understand that.
But it goes beyond that (primarily in the core PagefilesManager, Pagefiles, Pageimages, Pagefile, and Pageimage classes). So the considerations would stretch pretty far beyond just the module.
The only way I can think of to bypass that is to actually maintain a blank placeholder image file as the actual reference. The placeholder filename would be in some format where it could be identified as a reference, perhaps something like: page[id]-[fieldname]-[filename].jpg. Using that method, the core could continue to do what it does. When it deletes the image, it deletes the reference file rather than the original image. But when outputFormatting is on, the module would know to convert the images in that specific format to the one that is referenced. Still a bit complicated, but just thinking out loud how something like this might be accomplished, and this might be a way.
Yeah, this is what I tried to describe above. I think it would be sufficient to add an "id" column to the images/files (always have files in mind, why not treat them the same). And then just put the id of the referenced file in the "data" column. The outputFormatting has "only" to check if the data is a number (INT) and if so, just fetch the original/referenced data, could be a global function fetchOriginalFile() for example. If the original doesn't exist, the output does nothing, the inputField would render a message once (referenced file deleted [x] ). So I - from my noob point of view - think that extending the file/image table with an id column as well as extending the involved classes by a
if (is_int(image['data']) image['data'] = fetchOriginal(image['data']);
could work (pseudocode). But of course I don't know the internals of PW (yet).
I think a page[id]-[fieldname]-[filename].jpg looks a bit like a workaround, which is harder to extend. With the id approach I think it could be also easier to extend the file fields with more fields like title, tags and so on.
I am aware that PW usually encourages me to use pages for that, but especially the image upload function is so nice that I would rather use that
Also tagged with one or more of these keywords: image, inputfield
Community Support →
API & Templates →
Convert file field to image field during runtimeStarted by evanmcd, 12 Jun 2013 |
|
|
||
Community Support →
Getting Started →
Unable to get proper image url?Started by Godfrey, 02 Jun 2013 |
|
|
||
Community Support →
API & Templates →
Image "likes"Started by Sabir, 27 May 2013 |
|
|
||
Community Support →
Modules/Plugins →
Module/Plugin Development →
Add pixlr editStarted by Galaxy, 14 May 2013 |
|
|
||
Community Support →
Getting Started →
Fixed image sizeStarted by Eltom, 03 May 2013 |
|
|
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













