Photo field alignment

B

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

Ninox Profile

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.

B

Hi Sean, thank you very much for your reply.

I am struggling to understand that peice of code, bear with me.

Also, since I am in a dynamic view, the formula would need to point to a different picture depending on the selected record. I am using the Mac app and a local db.

 

Thanks!

 

Ninox Profile

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 the files() 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+.

Ninox Profile

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.

B

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

U

Hi Blued,

I am very interested to know how you managed to make in Ninox the application to build the family tree. Would you be so kind to give me this information?

Thank you very much.


Umberto

B

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

Ninox Profile

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;"">")

Ninox Profile

Here it is without the "style" part...

 

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") + """>")

Reply