This translation is older than the original page and might be outdated. See what has changed.

PH-Type PHOTO


PHOTO-Type Property.

     <prop name="FOTO" group="1" type="PH" labelwidth="0" fieldsize="100" onchange="Refresh255" width="100%" height="50%"/>



For a PHOTO type field, we will combine the use of a type=“T” field which will have the name of the file to transfer with a type=“IMG” field to be able to have a preview of the file, for this we make use of a button that calls to the camera and leaves this photo result in the text and image fields.

Example of code:

   <prop name="FOTO1" title="Foto 1" width="74%" labelwidth="6" disableedit="VALIDADO=1" text-border="true" class="texteditlocked" type="T" tmargin="20p" />
   <prop type="B" name="MAP_BTNFOTO1" img="camera.png" width="64p" height="64p" disableedit="VALIDADO=1" method="ExecuteNode(camera('FOTO1'))" newline="false" tmargin="10p" title=" " />
   <prop type="B" name="MAP_BTNDELFOTO1" img="deshacer.png" width="64p" height="64p" disableedit="VALIDADO=1" method="ExecuteNode(delcamera('FOTO1'))" newline="false" tmargin="10p" title=" " />
   <prop name="MAP_FOTO1" type="IMG" lmargin="35%" tmargin="1%" readonly="true" locked="true" onchange="refresh" width="30%" height="20%" file-maxwidth="800" file-maxheight="600" />
 
	<prop name="MAP_IMAGENES" type="Z" contents="imagenes" class="contentgridview" width="100%" height="400p" />
	<contents name="imagenes" src="ContentFileManagerImagen" filter="IDINCIDENCIA=##ID##" />
 
    <camera show-wait-dialog="false">
        <action name="runscript">
        <param name="CAMPO" />
          <script language="VBScript">
	          	ui.startcamera CAMPO,"photo"
		  </script>
        </action>
    </camera>
 
    <delcamera show-wait-dialog="false">
        <action name="runscript">
        <param name="CAMPO" />
          <script language="VBScript">
          		this(CAMPO)=""
		  </script>
        </action>
    </delcamera>
 
<!-- Si el campo donde hemos puesto la foto cambia y queremos meterla en el contents de fotos -->
      <onchange>
        <field name="MAP_FOTO">
          <action name="runscript">
            <script language="javascript">
					var cImagen = self.getContents("imagenes");
					var objImagen = cImagen.createObject();
					objImagen.FOTO = self.MAP_FOTO;
					objImagen.FECHA = formatDateTime(new Date(),0);
					if ( self.ID &gt; 0 ){
						objImagen.IDINCIDENCIA = self.ID;
					}
					cImagen.addItem(objImagen);
					objImagen.save();
            		ui.getView(self).refresh("MAP_IMAGENES");
				</script>
          </action>
        </field>
      </onchange>



Certain attributes have been incorporated to “limit” the upload of files in the type “AT” (Attach file), “IMG” (Signature), “VD” (Video) and “PH” (Photo).

Attributes:

Attribute Description
file-maxsize=“XXX” Size in bytes, maximum size of the file to upload.
file-msgfail=“Mensaje Error” We customize the error if we tray to upload a very big file.
file-maxwidth=“800” Maximum width of the photo taken.
file-maxheight=“600” Maximum height of the photo taken.

file-maxwidth and file-maxheight must be implemented for the photo and signature type fields in order the different devices replicate the photos and signatures always with the same resolution. This will make that the size of the photos be more predictable and of small size, and it will avoid memory problems in low-end devices.