• Resolved lewiscornwell

    (@lewiscornwell)


    Hello,

    This is working great within wp-admin which uses the media manager.

    However, my site allows users to add posts through an Advanced custom fields form. When uploading a media file this way it doesnt fire up the media library.

    Is there anyway I can generate thumbnails once the admin has approved the post? Or, when the post is submitted for review?

    https://www.ads-software.com/plugins/pdf-thumbnails/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter lewiscornwell

    (@lewiscornwell)

    I am trying to build a function, but without success!

    function gen_thumb($post_ID){
    	$attachmentId = get_field( "file_upload", $post_ID);
    	generateThumbnail($attachmentId);
    }
    add_action( 'publish_post', 'gen_thumb');
    Plugin Author stianlik

    (@stianlik)

    Hi,

    You can run the generation function manually using pdf_thumbnails_generate_attachment_metadata. E.g.

    function gen_thumb($post_ID){
    	$attachmentId = get_field( "file_upload", $post_ID);
    	pdf_thumbnails_generate_attachment_metadata(null, $attachmentId);
    }
    add_action( 'publish_post', 'gen_thumb');

    Note that this function is not part of the official PDF Thumbnails API so it may change in the future.

    EDIT: Changed $post_ID to attachmentId in sample.

    Thread Starter lewiscornwell

    (@lewiscornwell)

    Thank you very much, are you able to tell me if the rest of my function is correct as I cannot seem to get it working.

    Many thanks

    Plugin Author stianlik

    (@stianlik)

    Sorry, I should have used $attachmentId in the sample, please see the updated sample above. Other than that, your function should be correct.

    Heya – hope it’s ok that I’m jumping in here… I’m looking at trying out this plugin with ACF.

    About the function you wrote above: is that just something I’d post into functions.php? or is there somewhere else I should be place it?

    Plugin Author stianlik

    (@stianlik)

    You can paste the code into functions.php and it should work. However, it would be better to do this from a plugin so that the functionality is separate from your theme. If you’d like to go with a plugin, you can follow the instructions in the plugin handbook.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘ACF Front End Editor’ is closed to new replies.