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.
Announcement
Collapse
No announcement yet.
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:
Code:ifThen( string\contains(fileName, 'jpg') || string\contains(fileName, 'png'), abbildungId = fileId);
- Likes 1
-
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:
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.
- Likes 1
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.
- Likes 1
Leave a comment:
-
Originally posted by shalmaxb View PostHello,
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:
-
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 image
Leave 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
- Likes 1
Leave a comment: