
Photo field alignment
Hello,
a photo field is always aligned on the left when laying out a view. I need to have more fields on its left or even a space to center it on the page. Is there a way to do it?
Thank oyu very much
-
You can do it using a Formula field and the
html()
function. This is how you can do it using the Mac app and a local database...html("<img src=""/Users/YourUserName/Library/Containers/de.ninoxdb.ninox-mac.Ninox/Data/Documents/data/zImageTest/files/C/1/shutterstock_307218608.jpg"">")
I haven't done it using the Cloud version, but Jacques or someone else can probably help with that. You'll have to use the API.
-
Hi Blued,
From the outside to the inside... The
html()
function lets you run HTML, CSS and some JavaScript in a Formula field. <img src=...> is just an HTML image tag. The rest is the file path to the image file. "zImageTest" is my database name. "C" is the 3rd table in the database. "1" is the record number in the table. To do it dynamically I think you can use thefiles
() function, but you might have to do some parsing to get the file name right. I don't have time to check that right now.If you don't see "Library" in Finder, press command+shift+.
-
If you know that there is only one image attached per record you can use this formula and you only need to enter your Mac user name and the Ninox database name.
html("<img src=""/Users/YourUserName/Library/Containers/de.ninoxdb.ninox-mac.Ninox/Data/Documents/data/YourDatabaseName/files/" + extractx(text(files(this)), "(\w)(.+)", "$1/$2") + """>")
Otherwise, you'll need to filter out the correct image file.
-
Hi Sean,
I do appreciate your support.
Yes there is only one picture per record. I have updated your formula with my username and database name but there is no result, a small question mark icon is displayed in the formula field.
Also, I am displaying more records (one picture each) in the same view as I built a genealogical tree: I can display all records info depending on the genealogical relation, picture included, I just need to align/place the pic not on the left of the screen.
Again, thank you very much for your time
-
Hi Umberto,
firstly each record as a unique ID (not the incremental one automatically created by Ninox at the moment of the creation of the record). Secondly each record as a "father" and a "mother" fields with those unique IDs. This is the parental link.
The visual representation is with a view and I used empty "free text" fields with borders to represent the family tree. It is surely not elegant but it is working. Of course, it is a static tree and only parents and grandparents are displayed, no simblings nor uncles and haunts.
I hope it helps
-
Blued,
As long as you are doing this in a Form view and not a View layout element, it should work. The problem might be using the "this" keyword. I was able to display more than one image this way...
html("<img src=""/Users/YourUserName/Library/Containers/de.ninoxdb.ninox-mac.Ninox/Data/Documents/data/YourDatabaseName/files/" + extractx(text(files(record(YourTableName,NinoxRecordId))), "(\w)(.+)", "$1/$2") + """ style=""display: block; margin-left: auto; margin-right: auto; padding: 10px 0px 0px 0px;"">")
-
Blued,
That should be ok. As long as you aren't trying to display it in one of the table views, Table, Sub Table, View layout element, but it doesn't sound like that's what you're doing. I would remove the
html()
function from the formula and the Forumula field will display the img tab with the file path. Then follow the path in Finder and confirm whether they match or not. -
result from formula:
/Users/Vittorio/Library/Containers/de.ninoxdb.ninox-mac.Ninox/Data/Documents/data/Erythrure/files/A/427/m_a.jpeg
I can't see folder "427" and file "m_a.jpg" in Finder. I can only follow down to folder "A" that is empty
/Users/Vittorio/Library/Containers/de.ninoxdb.ninox-mac.Ninox/Data/Documents/data/Erythrure/files/A
folder "427" as per result of the formula is acutally the record ID and also filename is correct in the formula result