4 Replies Latest reply on Oct 13, 2011 1:25 PM by raybaudi

    Is there a way to limit the size of an image in a container field? Can this be a button?

    Mingrl88

      Title

      Is there a way to limit the size of an image in a container field? Can this be a button?

      Post

      Hello All,

      I have searched google and the FM forums and can not find a straightforward answer to this, so I thought I would post my own question in hopes to find a clear answer.

      In my database I have 4 container fields per material record. I'd like to make a limit on the size of the file (in this case image) that can go in the container field. I have heard that one way to do this is you can make a validated calculation with a "length limit" and I tried entering into the validation calulation:

      Length (Image1) < 204800

       

      I was told this was about 200kb and I am ok having it even be 500kb but when I tried to insert an image that was about 1.7Mb it did not object. What am I missing?

       

      Also, I have read multiple times that having a button for "insert image" will prvent users from copying and pasting images which increase the size and disjoin the filepath. I'd like to make this button but when I tried it asked me for a specific path which I do not have, nor will I ever, since the user who uploads the image is the only one who would know it, but my users may not understand this and I'd like for them to just be able to choose the image from a "browse" screen like the one that shows up when you right click the conainter field and hit "insert image".

       

      PLEASE help! Thanks!!

        • 1. Re: Is there a way to limit the size of an image in a container field? Can this be a button?
          philmodjunk

          When you inserted the 1.7Mb image, was "store by reference" enabled? This is a checkbox that appears in the dialog where you select the image file to insert. If "store by reference" is used, then only a file path to the image file is entered into the container field and this will be much smaller than your specified length limit.

          You should be ablet to configure Insert Picture so that the user gets the same "browse" dialog box that you get when you manually select the same option if you don't select any sorce file. Use Go To Field to put the cursor in the container field first, then your next step is Insert Picture. You can then control whether or not "by reference" is the default setting, but I don't see any way to make sure that the user doesn't select this option anyway...

          • 2. Re: Is there a way to limit the size of an image in a container field? Can this be a button?
            Mingrl88

            Hi Phil,

             

            Thanks for the advice! I was able to get an "insert image" button to show the browse screen when it opens but I am still having trouble limiting the size of the picture. I typed: Length (image1)<204800 into the validation calculation box for the field "image1" and tried to insert the image without the "store by reference" box checked and it still let me insert a 7mb image.I would like it to be limited to 500kb at least.

             

            Any thoughts!?! Thanks!

            • 3. Re: Is there a way to limit the size of an image in a container field? Can this be a button?
              philmodjunk

              Hmmm, it worked for me.

              Here's what I did:

              I opened a DB test file with a container field.

              I defined cLength as the calculation: Length ( ContainerField ) and placed it on my layout.

              I used Insert Picture to insert an image without the "by reference" option selected

              I copied the value of cLength to the clipboard. (2503647)

              I then added this validation calculation to containerField:

              Length ( self ) < 2500000

              I then created a new record and inserted the same image with the same options.

              When I committed the record by clicking the layout background, the validation error message popped up. If I has specified a custom validation message, this message could have told me that my image file was too large.

              • 4. Re: Is there a way to limit the size of an image in a container field? Can this be a button?
                raybaudi

                 Hi

                you could try to use an auto-enter calculation, instead of the validation option. Something like:

                Case(
                Length ( Self ) ≤ 204800 ; Self ;
                Self  & " ( " & Round ( Length ( Self ) / 1024 ; 0 ) & " kB ) is too large"
                )