Howto to resize (thumbnail) on upload file. How to reach the more easy example, for dummies. - Page 2

Howto to resize (thumbnail) on upload file. How to reach the more easy example, for dummies.

2»

Answers

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Allan,

    Now, it seems to be working, let me do more range of test and I tell you soon.

    My best greetings.

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Allan,

    Upload where sentence works with "fixed value" (below), but not when posting site parameter (now comment on code).

                    ->where( function ( $q ) use ( $site ) {
                        //$q->where( 'site', $site );
                        $q->where( 'site', "342800010" ); // ONLY for Test
                      } )
    

    I´ve try with $q->where( 'site', $site ); but don´t work

    As you mencioned above, "That assumes that you are posting the site parameter to the server with the upload action.",
    How I can to pass "site" to upload action (on what line/s)?

    Thank you!!

    My code:

    ...
    function id_establecimiento(results){
         var id_estblecmto = localStorage.getItem('establecimiento');
        return id_estblecmto
    };
    ...
        editor = new $.fn.dataTable.Editor( { 
                
            ajax: {
                url: parser_origin + "/_country/spain/v137/lacarte.restaurants.back/alacarte/php/chef_recomd.php",
                type: "POST",
                data: function ( d )    {
                    
                    $('#example').DataTable( {
                    d.site =  id_establecimiento(); 
                                        }
                    },
            table: "#example", 
    
            fields: [ {
                    label: "Nombre:",
                    name: "nombre",
                    status: "This field is required"
                    
                }, 
    ...
                {
                    label: "Imagen:",
                    name: "image",
                    type: "upload",
                    display: function ( file_id ) {
                        return '<img src="'+table.file ( 'files_chef_recomd', file_id ).web_path_thumb2+'"/>'; 
                    },
                    clearText: "Clear",
                    ajaxData: function ( d ) {d.append( 'site', id_establecimiento() ); }, // here I´ve add  " }, "
                    noImageText: 'No image'
                },
    
    ...
     var table = $('#example').DataTable( {
        responsive: true,
            dom: "Bfrtip",
            ajax: {
                url: parser_origin + "/_country/spain/v137/lacarte.restaurants.back/alacarte/php/chef_recomd.php",
                type: "POST",
                data: function ( d )    {
                    
                    d.site =  id_establecimiento();
                                        }   
                    },  
            columns: 
                [
            
                    { data: "nombre" },
                    { data: "condimentos" },
                    { data: "es_un" },
                    { data: "nota_item" },
                    { data: "precio"},
                    { data: "prec_terraza"},
                    { data: "alergeno" },
                    { data: "alergenos", render: "[, ].name" },
                    {
                        data: "image",
                        render: function ( file_id ) {
                            return file_id ?
                                
                                '<img src="'+table.file( 'files_chef_recomd', file_id ).web_path_thumb2+'" class="" width="120" height="79"/>' :
                                null;
                        },
                        defaultContent: "No image",
                        title: "Imagen"
                    },
    
                ],
    
    
  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,

    About to send "site" parameter to server-side, I´ve work on "ajaxData:.." on line 35, but I cannot get to past to server this parameter.
    Can you tell me any idea?

    Thank you!
    Eduardo

  • allanallan Posts: 61,765Questions: 1Answers: 10,111 Site admin

    That does look like it should work. Could you give me a link to a page showing the issue so I can debug it please?

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1
    Answer ✓

    Hi Allan,
    Your are right , it´s works! ( was a mistake of my test, my apologies)

    Let me a last question for well understand: the "site" parameter for upload action (and others parameters, if are needed) are sent on 35 line? (below).

    Thank you for you help,
    My Greetings.

    ajaxData: function ( d ) {d.append( 'site', id_establecimiento() ); },
    
  • allanallan Posts: 61,765Questions: 1Answers: 10,111 Site admin

    Yes, you can modify the FormData object inside that callback by appending parameters to it, exactly has you have done.

    Allan

  • aneto2400aneto2400 Posts: 58Questions: 8Answers: 1

    Hi Allan,
    All right and take note.

    Thank you for you help and for your time,
    Greetings

This discussion has been closed.