Announcement

Collapse
No announcement yet.

image in grid

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

  • image in grid

    Hello,

    I am new to scriptcase and try to show a image from file into a grid based on some fields of the record.
    I can do this by using the event "on record", but i keep on getting errors.

    Is there a tutorial or example how to do this?
    And where should i place all the images?

    My images are divided over multiple folders as:
    Images - Categorie A
    - Categorie B
    - Categorie C - Sub categorie 1
    - Sub categorie 2
    - Sub categorie 3 - Picture product A
    - Picture product B
    - Picture product C

    Kind regards,

    Marco

  • #2
    if this images are accesible via webbrowser, just construct "onRecord" the img tag. Something like:

    Code:
    <img src="http://yoursite.com/". imagesFolder ."//".categoryNeeded."//".imageName>
    /Giuseppe

    Professional Scriptcase Services
    Some Customers opinions

    Comment


    • #3
      Thanks, i will try that.

      Comment


      • #4
        Thanks for the tip. I have it working.

        Is there a way to check if the image exists? Then i could show a standard picture.

        Kind Regards,

        Marco

        Comment


        • #5
          Yes.

          http://php.net/manual/en/function.file-exists.php
          /Giuseppe

          Professional Scriptcase Services
          Some Customers opinions

          Comment


          • #6
            Just extend your image tag.

            <img src="http://yoursite.com/". imagesFolder ."//".categoryNeeded."//".imageName onerror = "this.src='path_to_default_image'" />

            jsb

            Comment


            • #7
              Thanks you... it works great.

              Comment


              • #8
                Originally posted by Giu View Post
                if this images are accesible via webbrowser, just construct "onRecord" the img tag. Something like:

                Code:
                <img src="http://yoursite.com/". imagesFolder ."//".categoryNeeded."//".imageName>
                Hello,

                I'm interested in this but like to reduce time spent debugging errors. So before I try can I clarify: if you refer to fields in onRecord as {fieldname}, how does the code you supplied here link up to a specific field in the grid?or is it meant to be {img}?

                Comment


                • #9
                  good day an new year.
                  excuse me my english.
                  i have folder in htdocs site main fotos
                  i have code for view image in grid, the file name is itemid.png. i shared code.
                  in event onrecord have view_imageitemid();

                  1.the var [glo_path_img] = name folder "/fotos/"
                  2. file image i use for image small and image large. uses property the file with and heigh
                  3. use 2 field {image} for large and use field {img_size } for viem small in grid.



                  $longitud1= strlen({ITEMID});
                  $variable={ITEMID};
                  $longitud=strlen($variable);
                  $itemid=trim({ITEMID});
                  $serverport=getenv('SERVER_PORT');
                  $serverIP=getenv('SERVER_ADDR');

                  IF ($serverport<>'80')
                  {
                  $path_url='HTTP://'.$serverIP.':'.$serverport;
                  }
                  else
                  {
                  $path_url='HTTP://'.$serverIP;
                  //getenv('SERVER_ADDR');
                  }


                  $nombre_fichero=[glo_path_img].$itemid.'.png';
                  $validfile=getenv('DOCUMENT_ROOT').$nombre_fichero ;

                  /**
                  * Validar existencia del archivo antes de usarlo en la URL
                  */

                  if (file_exists($validfile))
                  {

                  $nombre_fichero=$path_url.[glo_path_img].$itemid.'.png';
                  $result = @getimagesize($nombre_fichero);
                  list($width, $height, $tipo, $atributos) = @getimagesize($nombre_fichero);
                  if ($data = @getimagesize($nombre_fichero))
                  {
                  $width=(25*$width)/100;
                  $height=(25*$height)/100;
                  //echo $data[1];
                  {IMAGEN}="<img src='$nombre_fichero' border='0' width='$width' height='$height' >";
                  $width=(300*$width)/100;
                  $height=(300*$height)/100;
                  {IMG_SIZE}="<img src='$nombre_fichero' border='0' width='$width' height='$height' >";
                  }
                  }else
                  {

                  $path_url='HTTP://'.getenv('SERVER_ADDR').':'.getenv('SERVER_PORT');
                  $nombre_fichero=$path_url.[glo_path_img].'error'.'.png';
                  list($width, $height, $tipo, $atributos) = @getimagesize($nombre_fichero);
                  if ($data = @getimagesize($nombre_fichero))
                  {
                  $width=(25*$width)/100;
                  $height=(25*$height)/100;
                  {IMAGEN}="<img src='$nombre_fichero' border='0' width='$width' height='$height' >";
                  }

                  }
                  Last edited by ayepes2003; 01-08-2015, 07:49 PM.

                  Comment


                  • #10
                    Originally posted by scriptcaser View Post
                    Hello,

                    I'm interested in this but like to reduce time spent debugging errors. So before I try can I clarify: if you refer to fields in onRecord as {fieldname}, how does the code you supplied here link up to a specific field in the grid?or is it meant to be {img}?
                    onRecord event fires for every record on a grid. If you overwrite the content with an HTML tag, this is the content will be displayed in the field.
                    If field in grid is called myImage, you can onRecord do something like:
                    {myImage} = <img src="ok.png">

                    And all records will have the ok.png image in the field. If you construct the img tag with variables, well, you can think about the possibilities.
                    /Giuseppe

                    Professional Scriptcase Services
                    Some Customers opinions

                    Comment

                    Working...
                    X