Announcement

Collapse
No announcement yet.

Display image in documents entity when document file is an image

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • shalmaxb
    commented on 's reply
    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.

  • esforim
    commented on 's reply
    Sorta off-topic. Can we also thumbnails PDF?

  • shalmaxb
    replied
    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);
    This means, whenever the uploaded file has the format .jpg or .png, the imageId will be the fileId.​

    Leave a comment:


  • rabii
    replied
    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'nullnull'id='fileId);

    $type record\attribute('Attachment'$fileId'type');

    ifThen($type == 'application/pdf',
        
        
    // your logic goes here
    );​ 
    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.

    I hope this make sense.

    Leave a comment:


  • shalmaxb
    commented on 's reply
    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.

  • rabii
    commented on 's reply
    Cool
    Whay happens if the type == bild and the file is not an image ? do you test the extension of the file ?

  • shalmaxb
    replied
    illustration of that

    Leave a comment:


  • esforim
    commented on 's reply
    I'm surprise this even work! Another thread added to my never-ending list to experiment.

  • rabii
    replied
    glad you sorted it out.

    Leave a comment:


  • shalmaxb
    replied
    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:


  • rabii
    replied
    Originally posted by shalmaxb View Post
    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?
    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 ?)

    Leave a comment:


  • item
    replied
    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);​ 
    not understand "corrupt".. print-screen ?

    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?
Working...
X