Задать вопрос
Ответы пользователя по тегу JavaScript
  • Как настроить eslint?

    @alexsandr_s
    а вы readme к linter-eslint читали? там же все понятно написано.
    Ответ написан
    Комментировать
  • Как получить attachment.url'ы двух или более выделенных изображений?

    @alexsandr_s Автор вопроса
    решил, нужно было обернуть в
    jQuery(document).ready(function($){
    });

    Полный код
    jQuery(document).ready(function($){
    var file_frame;
    $('#upload').live('click', function(event) {
        event.preventDefault();
        
        // If the media frame already exists, reopen it.
    
        if (file_frame) {
            file_frame.open();
            return;
        }
        // Create the media frame.
        file_frame = wp.media.frames.file_frame = wp.media({
            title: 'Choose Image',
            button: {
                text: 'Choose Image'
            },
            multiple: true
        });
        // When an image is selected, run a callback.
        file_frame.on('select', function() {
            var selection = file_frame.state().get('selection');
            selection.map( function( attachment ) {
            attachment = attachment.toJSON();
             // Do something with attachment.id and/or attachment.url here
            $("#featured-footer-image-container").after("<img src=" +attachment.url+" width='100' height='100'>");
            });
        });
        file_frame.open();
    });
    });
    Ответ написан
    Комментировать