• Does anyone know how to enable this? I have a second wordpress blog that had this “feature” enabled. I can’t for the life of me remember how it was done. Based on a diff, I haven’t modified the plugin code at all.

    Just to be clear, in my old blog, I’m able to insert a Link To as “Large File URL” and no code has been changed in the plugin. I don’t have it in my new blog.

Viewing 1 replies (of 1 total)
  • Thread Starter fusionstream

    (@fusionstream)

    As usual, after deciding to post the question, I find the answer myself.

    If you’ve come across it before, please be advised that the ‘title’ field has to be changed to ‘data-link-url’ for it to work with wordpress 4.7.2 and possibly for earlier versions.

    This be the code:

    add_filter('attachment_fields_to_edit', 'large_attachment_fields_to_edit', 0, 2);function large_attachment_fields_to_edit($fields, $post){ if (substr($post->post_mime_type,0,5) == 'image'){ $html = "<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr(array_shift( wp_get_attachment_image_src($post->ID, 'large', false) )) . "' /><br /> <button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button> <button type='button' class='button urlfile' data-link-url='".esc_attr(array_shift( wp_get_attachment_image_src($post->ID, 'large', false) ))."'>Large File URL</button> <button type='button' class='button urlfile' data-link-url='" . esc_attr(wp_get_attachment_url($post->ID)) . "'>" . __('Original File URL') . "</button> <button type='button' class='button urlpost' data-link-url='" . esc_attr(get_attachment_link($post->ID)) . "'>" . __('Post URL') . "</button>"; $fields['url']['html'] = $html; } return $fields;}

    You’re supposed to put it in the functions.php of your theme but I just put it inside the site specific plugin (which is just a basic plugin that you create so you can put your modified code there instead)

    My site specific plugin has this code:

    <?php
    /*
    Plugin Name: Site Plugin for yoursite.com
    Description: Site-specific code changes for yourside.com
    */
    /* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */
    add_action( 'after_setup_theme', 'default_attachment_display_settings' );
    function default_attachment_display_settings() {
        update_option( 'image_default_align', 'none' );
        update_option( 'image_default_size', 'custom' );
    //    update_option( 'image_default_link_type', 'file' );
        add_filter('attachment_fields_to_edit',  'large_attachment_fields_to_edit', 0,  2);
        function large_attachment_fields_to_edit($fields, $post) {
            if (substr($post->post_mime_type,0,5) == 'image') {
                $html = "<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='"
                        . esc_attr(array_shift( wp_get_attachment_image_src($post->ID, 'large', false) )) . "' /><br />                                <button type='button' class='button urlnone' data-link-url=''>"
                        . __('None') . "</button>                                <button type='button' class='button urlfile' data-link-url='"
                        .esc_attr(array_shift( wp_get_attachment_image_src($post->ID, 'large', false) ))
                        ."'>Large File URL</button>                                <button type='button' class='button urlfile' data-link-url='"
                        . esc_attr(wp_get_attachment_url($post->ID)) . "'>"
                        . __('Original File URL') . "</button>                                <button type='button' class='button urlpost' data-link-url='"
                        . esc_attr(get_attachment_link($post->ID)) . "'>" . __('Post URL')
                        . "</button>";
                $fields['url']['html'] = $html;
            }
            return $fields;
        }
    }
    /* Stop Adding Functions */
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Custom “Link URL” sizes.’ is closed to new replies.