From espoCRM itself that is not possible. But perhaps one could implement something like this: https://github.com/andreysaf/nodejs-convert-file-server
although it is beyond my skills.
Display image in documents entity when document file is an image
Collapse
X
-
Hi, as I always try to achieve my solutions by formula, I tried this and it works also:
This means, whenever the uploaded file has the format .jpg or .png, the imageId will be the fileId.Code:ifThen( string\contains(fileName, 'jpg') || string\contains(fileName, 'png'), abbildungId = fileId);
-
hey shalmaxb
You could actually check the type of an attchment because the file on document and the image you have on the document they are both attchamnets, therefore you can access the record and get their type e.g check the type of the file on document will be as below:
It will be safe to check the currect type of the file because the user can provide wrong info imagine a user choose the type (graphics) and they upload pdf instead they will bypass your logic and this might cause issue because your code will try to assign the pdf to an image field which will result in error due to extension incompatinility.PHP Code:$attachmentId = record\findOne('Attachment', null, null, 'id=', fileId); $type = record\attribute('Attachment', $fileId, 'type'); ifThen($type == 'application/pdf', // your logic goes here );
I hope this make sense.Leave a comment:
-
The user has to choose, what type it is. If the user chooses for example document, the image field will not be present at all (conditional display). I provide the following types: graphics (image), image (image), labelling (special field for my app), which are all from type image. In the formula I provide theses types in form of type == image || type == graphics || type == labelling. So my illustration above is a shortened presentation.
I also provide for types documents (PDF, txt, doc, etc.). The user chooses one of the types and by the formula, the image field is only displayed, like allowed for type == image.
To check this against the file extension could be possible by coding, but I think not by formula. But would be a nice feature, ehich would make this independent from a user`s choice. -
item and rabii
Thank you for your help. Meanwhile I saw, that there was another error, which caused my initial idea not to work. After correcting it works as desired.
For information, what I am achieving:
In my documents I sometimes have images as file. To display these images in detail and list view I created an image field and fetch the file Id of the image to copy it to the image field (by formula). This way the image is displayed, whereas with the default file field, there is only the linked file symbol.Leave a comment:
-
can you share a screenshot of what you are trying to achieve ? not yet sure why you have an imgae field and you have to set it up imageId = field (what is the field ?)Hello,
so far I displayed the image of an image file in documents in an image field, which I populated by formula imageId = fileId. For itself it worked, but formula in documents is a problem as it corrupts the folder functions. So I had to discard the mentioned approach.
Any idea, how I could realize something like that?Leave a comment:
-
not understand "corrupt".. print-screen ?PHP Code:$attachmentId = record\findOne('Attachment', 'createdAt', 'ASC', 'relatedType', 'Document', 'relatedId', id); $type = record\attribute('Attachment', $attachmentId, 'type'); ifThen( $type == 'image/jpeg' , pictureId = $attachmentId); output\printLine(pictureId);
maybe ifThenElse with a "allInOne.jpg" type of file or for each type :
application/zip => zip image
text/csv => txt/csv image
application/pdf => pdf imageLeave a comment:
-
Display image in documents entity when document file is an image
Hello,
so far I displayed the image of an image file in documents in an image field, which I populated by formula imageId = fileId. For itself it worked, but formula in documents is a problem as it corrupts the folder functions. So I had to discard the mentioned approach.
Any idea, how I could realize something like that?Tags: None

Leave a comment: