Forum Replies Created

Viewing 12 replies - 166 through 177 (of 177 total)
  • Plugin Author Mizuho Ogino

    (@fishpie)

    It is exactly what you point out.

    The [0] is an unused code and should be removed. It’s kind of dead code from older versions. Following the advice, I take it from the image name and modified the plugin. Please update it.

    Thanks for great feedback!!

    Plugin Author Mizuho Ogino

    (@fishpie)

    Hi ferne97.

    It may be specific problem of your systems. Some hosting services disable exec command for security reasons.

    Anyway, I updated version and changed the way to check exec command in an activation. I hope it helps you.

    Thank you.

    Plugin Author Mizuho Ogino

    (@fishpie)

    Hi derrickmg.

    Activate the plugin and add this code to your functions.php.
    Then, Click “Regenerate PDF” link in “settings”.
    After generating images, remove function from your php.

    Thank you.

    function regenerate_pdf_image_menu() {
      add_options_page('Force regenerate uploaded PDFs', 'Regenerate PDF', 5, 'regenerate_pdf', 'regenerate_pdf_image_page');
    }
    function regenerate_pdf_image_page() {
      echo '<div class="wrap"><h2>Regenerate uploaded PDFs</h2>';
    	$pdfs = get_posts(array('post_type'=>'attachment','post_mime_type'=>'application/pdf','numberposts'=>-1));
    	if($pdfs): foreach($pdfs as $pdf):
    		$thumbnail_id = get_post_meta( $pdf->ID, '_thumbnail_id', true );
    		if( $thumbnail_id ){
    			echo 'attachment id: '.$pdf->ID.' / A thumb is already exist.<br/>';
    		} else {
    			pigen_attachment($pdf->ID);
    			echo 'attachment id: '.$pdf->ID.' / A thumb is generated!! <br/>';
    		}
    	endforeach; endif;
      echo '</div>';
    }
    add_action('admin_menu', 'regenerate_pdf_image_menu');
    Plugin Author Mizuho Ogino

    (@fishpie)

    I decide to comment out the process of generating a test file.

    Because, it doesn’t relate to the function of the plugin itself.

    Sometimes, creating a folder can cause problems, and it’s difficult to reproduce the same situation. Keeping the function simple is good for the plugin.

    Thank you very much for the feedback!

    Plugin Author Mizuho Ogino

    (@fishpie)

    Hi Matthew.

    Thank you for pointing it out. It’s very precise.

    I should change the activation process to make a temporary directory and generate jpg file in it.

    I’m a bit tied up, but I will fix it as soon as possible.

    Plugin Author Mizuho Ogino

    (@fishpie)

    Yeah, it does not relate to the plugin.
    I guess, When you upload an attachment on front end, there is no post ID. So, it needs a little tricky way.

    At first, set a particular post to an upload button.

    wp_enqueue_media( array( 'post' => $post->ID )); // upload file to submitpage

    And, write these functions in your functions.php.

    <?php
    
    function tempo_id_for_frontend( $attachment_id ){ // run after an attachment is added to the DB
        global $post;
        $user_id = get_current_user_id();
        $submit_id = get_page_by_path( 'submitpage' )->ID;
        $attachment = get_post( $attachment_id );
        if ( $attachment->post_parent == $submit_id && $user_id ){
            $tempo_ids = get_post_meta( $submit_id, 'id_for_frontend', true); // set attachment ID in the customfield of "submitpage"
            if( !$tempo_ids ) $tempo_ids = array();
            $tempo_ids = $tempo_ids += array( $attachment_id => $user_id );
            update_post_meta( $submit_id, 'id_for_frontend', $tempo_ids );
        }
        return $attachment_id;
    }
    add_filter( 'add_attachment', 'tempo_id_for_frontend', 99, 2 );
    
    function save_post_for_frontend ( $post_id ) {
        if ( !is_admin() ){
            $user_id = wp_get_current_user()->ID;
            $submit_id = get_page_by_path( 'submitpage' )->ID;
            if( get_post_type( $post_id ) === 'your_custom_post_type_here' && $user_id ){ // set "post", "page", or your custom posttype
                $tempo_ids = get_post_meta( $submit_id, 'id_for_frontend', true);
                if( $tempo_ids ) : foreach ($tempo_ids as $key => $val ) : // pick attachment IDs from the customfield
                    if ( $val == $user_id ){
                        $at_post = array();
                        $at_post['ID'] = $key;
                        $at_post['post_parent'] = $post_id; // set post_parent
                        wp_update_post( $at_post );
                    }
                    unset( $tempo_ids[$key] );
                endforeach; endif;
                if( $tempo_ids ) update_post_meta( $submit_id, 'id_for_frontend', $tempo_ids );
                else delete_post_meta( $submit_id, 'id_for_frontend' );
            }
        }
    }
    add_action( 'save_post', 'save_post_for_frontend' );
    
    ?>
    
    Plugin Author Mizuho Ogino

    (@fishpie)

    This plugin hooks into “add_attachment” filter and only writes a thumbanil_id. It doesn’t touch attachment itself. You don’t show the code for how a media uploader is created on front-end, so it’s all I can guess.

    Thank you.

    Plugin Author Mizuho Ogino

    (@fishpie)

    Hello Damyang.

    Your server has completely enough memory to work the plugin.
    I’m sorry for wasting your time because my explanation was not clear.

    It may be because Ghostscript.
    The plugin requires ImageMagick with GhostScript support to process pdf files.
    If you didn’t install it yet, install it and try activate again please.

    I will add a process to verify ghostscript support in the near future.
    Tahnk you.

    Plugin Author Mizuho Ogino

    (@fishpie)

    I updated the plugin to version1.1.1 and changed the code to avoid imagemagick colorspace bugs. I hope it works as supposed.

    There are still some problems. The Plugin doesn’t convert some pdfs which made by apps like MS word. But things basically work.

    I will continue to improve the plugin. Thank you for the feedback!

    Plugin Author Mizuho Ogino

    (@fishpie)

    I updated to version 1.1 and added support for imagick API.

    Not quite sure what cause your problem. I couldn’t reproduce your problem…. But it’s probably the exec() command affect this behavior.

    I hope it can help you. Thanks.

    Plugin Author Mizuho Ogino

    (@fishpie)

    Could you tell what version of WordPress and PHP you are using?

    You must have imageMagick installed in server. Some hosting providers don’t pre-install ImageMagick.

    If imageMagick is already available, memory capacity of your server may cause ImageMagick to fail.

    Plugin Author Mizuho Ogino

    (@fishpie)

    If exec() is limited by “disable_functions”, and even if you can modify php.ini file, just remove “exec” from “disable_functions” and save the changes.

    I’d recommend you to contact your host and ask them whether it’s possible to enable exec().

Viewing 12 replies - 166 through 177 (of 177 total)