WP Table with images in cell

Hi

I try to get a list in WP with images in one column. This works very well as long I choose a fixed width, so the row height will increase when the image has portrait proportions.
When I try to use a fixed height to keep all rows at the same height, the image overlaps the cell and the image content is cut off. I just want to have the image shrinked proportional to the cell width.

[]32455013;“Image overlaps column…”[/]

Should be like this:
[]32454999;“should look like this, fixed height, proportional image”[/]

Someone an idea how to get this?

:slight_smile:

Product :4D - 4D Server
OS : Mac OS X
4D : v17R6

Hello Adrian

Here is a sample of code to help you manage this

  • 1st, you have to know id the picture is portait or landscape; According to this you have to set the attribute of the picture (not the cell) itself
  • Then you may (or not) decide of the rows and columns have to be resized or not

<code 4D>
wp:=WP New

$table:=WP Insert table(wp;wk append;wk include in range)

ALL RECORDS([samples])
$n:=Records in selection([samples])
For ($i;1;$n)
GOTO SELECTED RECORD([samples];$i)
$row:=WP Table append row($table;“alpha”;“bravo”;[samples]pict)

$pictrange:=WP Picture range($row)
PICTURE PROPERTIES([samples]pict;$width;$height)
If ($width>$height)
	WP SET ATTRIBUTES($pictrange;wk width;"2.5cm";wk height;wk auto)
Else 
	WP SET ATTRIBUTES($pictrange;wk height;"2.5cm";wk width;wk auto)
End if 

End for

// all the rows set to 3cm
$rows:=WP Table get rows($table;1;MAXLONG)
WP SET ATTRIBUTES($rows;wk height;“3cm”)

// distinct width for each columns
$cell:=WP Table get cells($table;1;1;1;1)
WP SET ATTRIBUTES($cell;wk width;“5cm”)

$cell:=WP Table get cells($table;2;1;1;1)
WP SET ATTRIBUTES($cell;wk width;“4cm”)

$cell:=WP Table get cells($table;3;1;1;1)
WP SET ATTRIBUTES($cell;wk width;“3cm”)

</code 4D>

Here is a tiny sample database i just wrote for you.
Quick and dirty, but should help !

https://forums.4d.com/4DBB_Main/x_User/4028/files/32467160.zip

Regards,

Roland

Hi Roland

Thank you very much for your help. In the meantime I ‘solved’ this by using a default size blank image and combining the picture on it, so that all images have the same proportions. Not very elegant, but works for now.

I will have a look at your solutions that I would prefer. :slight_smile:

Best

Adrian