After hours of trying I found a solution.
It was inspired by this post: http://nathanw.net/2011/09/05/qgis-tips-custom-feature-forms-with-python-logic/
It's not possible to link the attribute from the table with UI file directly. To display a photo in a custom form, the user needs an addtitional python script. Let's call it startForm.py . Its content is as follows:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
fotoField = None
myDialog = None
myDialog = dialog
global nameField, layerField, objectField
fotoField = dialog.findChild(QLabel,"Foto")
fotoPath=attr ##the file path to the image is stored right here
The script displays a picture in the form, as well as it changes the layer name and the feature id.
I load all my layers from a plugin window and I add those 2 lines to the code, so that each layer is already linked with the form:
##A piece of my plugin code; section: insert layers
In this case, the UI file and the startForm.py should be stored in the plugin directory.