Support

Account

Home Forums Backend Issues (wp-admin) Add featured img with URL input form

Unread

Add featured img with URL input form

  • Hi,

    I tried for a moment to put the featured image thanks to an external link. This link comes from google books api (I insert it into an input to have the link). I would like that when the form is submit the image is displayed featured in the post.
    I have the script for google api and one form.

    Thanks
    this is code for take informations about books

    $('body').on('click', '#results option', function () {
            var id = $(this).val();
            $.getJSON('https://www.googleapis.com/books/v1/volumes?langRestrict=fr&q=ISBN' + id, function (bookimg) {
    
                
                $('#image_livre').html(' <p><img src="' + bookimg.items[0].volumeInfo.imageLinks.thumbnail + '" /></p>');
                
                $('#acf-field_5b72fa2fbe46d').html('"' +bookimg.items[0].volumeInfo.imageLinks.thumbnail+ '" ');
                $('#field_5b758f5b7ea02').html('"' +bookimg.items[0].volumeInfo.imageLinks.thumbnail+ '" ');
    
                //            $('.#results').click(function () {
                //                $('.textInMce').html('');
                //            });
            });

    And this is the form

     <div class="form-group">
                            <label for="title">Rechercher un livre</label>
                            <br/>
                            <input id="researchbytitle" class="form-control" type="text" placeholder="titre"></div>
                        <p><label for="liste-livres">liste-livres</label>
                            <br/>
                            <select multiple class="form-control" id="results"> </select><br/>
                            <button id="button" type="button">Suivant</button> </p>
                            <div id="image_livre"></div>
                        <?php
                    if ( ! ( is_user_logged_in() ||
                            current_user_can('publish_posts') ) ) {
                        echo '<p>You must be a registered author to post.</p>';
                    } else {
                        acf_form(array(
                         'post_id' => 'new_post',
                         'field_groups' => array(60,71), // Used ID of the field groups here.
                         'post_title' => true, // This will show the title filed
                         'post_content' => true, // This will show the content field
                         'form' => true,
                         'new_post' => array(
                             'post_type' => 'Post',
                             'post_status' => 'publish' // You may use other post statuses like draft, private etc.
                         ),
                         'return' => '%post_url%',
                         'submit_value' => 'Submit post',
                     ));
                }
                ?>
Viewing 1 post (of 1 total)

The topic ‘Add featured img with URL input form’ is closed to new replies.