Forum Replies Created

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter Gabriel

    (@gafma)

    Works like a charm.
    Thanks Greg.

    Works fine Greg, thanks.

    zzkamikazezz, I did a quick solution that is really much easy.

    I named the folder and plugin with “my-force-featured-image” and my-force-featured-image.php respectively, to avoid conflict with existent plugin force featured image, like Greg said.

    Put the snippet into the file and create a header plugin, like this:

    /*
     * Plugin Name: My Force Featured Image
     * Plugin URI: https://wpadverts.com/
     * Description: This code snippet/plugin forces user to select a featured image or selects it for the user automatically.
     * Author: Greg Winiarski
     */

    I will try. Thanks Greg.

    I used this snippet like a plugin.
    An update was released (0.2.0).
    The author informed is X-Team, Jonathan Bardo
    When i updated the script it not work.
    Am I doing something wrong?

    force-featured-image-wp-advert

    This code works fine, but the update(0.2.0 – X-Team, Jonathan Bardo) I could not make it work.

    Thread Starter Gabriel

    (@gafma)

    the plugin mp3 jplayer does not have adequate support.

    Hi, Greg.
    I had the same problem. When you click in another INPUT field the select closes, but, the adjacent field is DESCRIPTION and, when you click there the select no closes.

    This problem occur in majority of mobile devices.

    To workaround this problem, would nice if you setup a js function to close the category select when the focus change out.

    Thread Starter Gabriel

    (@gafma)

    Its so simple.
    Excuse me my ignorance. Thanks.

    In time, this plugin is a really well programed, and works tremendously nice.

    Thread Starter Gabriel

    (@gafma)

    At first, I could not see the pagination (the bottom line menu).

    After insert more test ads, I realize that in adverts list page are show 20 adverts. But I did not found where change the number of adverts that show in list page.

    Thread Starter Gabriel

    (@gafma)

    Well, you are using this plugin (imsanity)? It solves exactly this problem.

    Portuguese
    Bom, você está usando este plugin (imsanity)? Ele resolve exatamente este problema.

    BR

    ░░░░░░░░░░░░▄▄
    ░░░░░░░░░░░█░░█
    ░░░░░░░░░░░█░░█
    ░░░░░░░░░░█░░░█
    ░░░░░░░░░█░░░░█
    ███████▄▄█░░░░░██████▄
    ▓▓▓▓▓▓█░░░░░░░░░░░░░░█
    ▓▓▓▓▓▓█░░░░░░░░░░░░░░█
    ▓▓▓▓▓▓█░░░░░░░░░░░░░░█
    ▓▓▓▓▓▓█░░░░░░░░░░░░░░█
    ▓▓▓▓▓▓█░░░░░░░░░░░░░░█
    ▓▓▓▓▓▓█████░░░░░░░░░█
    ██████▀░░░░▀▀██████▀

    Thread Starter Gabriel

    (@gafma)

    Thanks until now bcworkz.

    It is unlikely to be this. The dropbox backend script that I informed, works in both versions of codes.

    I will verify again, but this script works fine.
    I check de default upload directory and the register in the wp_post table. THe image was correclty registered in WP.

    I saw in somewere that wp_generate_attachment_metadata searches the mime type through the attach_id. Well, is all right in wp_post, so the image was correctly register in wp. I still dont understand why wp_generate_attachment_metadata works in one script and no at in another.

    I will keep investigating.

    Thread Starter Gabriel

    (@gafma)

    I verified everything, but not looks like wrong.
    The image upload is done by two steps:
    First the images are dynamically send to server by dropzone. The script is very simple. That works fine.

    <?php
    require_once($_SERVER['DOCUMENT_ROOT']."/test/site0/wp-load.php");
    
    	if ( ! function_exists( 'wp_handle_upload' ) ) {
        require_once( ABSPATH . 'wp-admin/includes/file.php' );
    }
    
    if (!empty($_FILES)){
    
    	$uploadedfile = $_FILES['file'];
    
    $upload_overrides = array( 'test_form' => false );
    
    $movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); //put in wordpress default directory
    
    if ( $movefile && !isset( $movefile['error'] ) ) {
    
    				imsanity_handle_upload($movefile);  //plugin to resize image
    
        echo $movefile['url']; //response to front-side script
    } else {
        /**
         * Error generated by _wp_handle_upload()
         * @see _wp_handle_upload() in wp-admin/includes/file.php
         */
        echo $movefile['error'];
    }
    
    	}
    			?>

    In front-end, a input field holds the images urls returned by script above, separated by commas.
    When the formulary is submitted, those urls are processed by script I talked in first message. And that not work. Process the image, set the thumbnail but dont generate metadata.

    In another version, I process just one image send directly to file in form action. This one works, but i need the first one.

    $cont = 1;
                foreach ($_FILES['my_image_upload']['tmp_name'] as $key) {
                  $title = ereg_replace("[^a-zA-Z0-9_]", "", strtr($_POST["vehicle_title"], "áàãâéêíóôõúüçÁÀÃÂÉÊÍÓÔÕÚÜÇ ", "aaaaeeiooouucAAAAEEIOOOUUC_"));
                  $content = file_get_contents($_FILES['my_image_upload']['tmp_name'][$key]);
                  $ext = strtolower(substr($_FILES['my_image_upload']['name'][$key],-4));
                  $title = substr($title,0,30);
                                                                 //short the title 30 chars
                  $title = $title . ++$cont . $ext;
                  //adicionar a extensão
                  $upload_dir = wp_upload_dir();
                  $aux = date('Y-m-d')."-".$title; //final title
                                               //add date to title
                  $namae = $upload_dir['path']."/".$aux;       //mount path
    
                  $file = fopen($namae,'x');
                  fwrite($file,$content);
                  fclose($file);
                  //parameters for plugin Imsanity, thats resize image
                  $params['type'] = image_type_to_mime_type(exif_imagetype($namae));
                  $params['file'] = $namae;
                  $params['url'] = $upload_dir['url']."/".$aux;
    
                  imsanity_handle_upload($params); 
    
                  $attachment = array(
                   'guid' => $params['url'],
                   'post_mime_type' => $params['type'],
                   'post_title' => sanitize_file_name($aux),
                   'post_content' => '',
                   'post_status' => 'inherit'                );               
    
                  $attach_id = wp_insert_attachment( $attachment, $params['file'], $pid );  
    
                   //generate metadata
                  require_once( ABSPATH . 'wp-admin/includes/image.php' );
                  $attach_data = wp_generate_attachment_metadata( $attach_id, $params['file'] );
                  wp_update_attachment_metadata( $attach_id, $attach_data );
                  set_post_thumbnail( $pid, $attach_id );
                                }//END FOR EACH

    Dropzone reference

    Thread Starter Gabriel

    (@gafma)

    I solved this.
    The option ‘Images uploaded elsewhere (Theme headers, backgrounds, logos, etc)’ in plugins settings must be configured to a non-zero value to imsanity_handle_upload($params); to work.

    Thread Starter Gabriel

    (@gafma)

    Thread Starter Gabriel

    (@gafma)

Viewing 15 replies - 1 through 15 (of 15 total)