• Resolved poppoll2

    (@poppoll2)


    After updating to 2.4 I lost the filename&ID I added with a mod to the media library in grid view.
    If I deactivate Enhanced Media Library the filename and ID is back.

    I Modified wp-includes/media-template.php with this code:

    
    line 452
    AFTER:
    <div class="centered">
    						<img src="{{ data.size.url }}" draggable="false" alt="" />
    					</div>
    ADDED:					
    					<!-- mod-->
    					<div class="filename">{{ data.filename}} - id:{{data.id}}</div>
    					<!-- end mod -->
    BEFORE:
    <# } else { #>
    					<div class="centered">
    						<# if ( data.image && data.image.src && data.image.src !== data.icon ) { #>
    

    How can I have this back without deactivating Enhanced Media Library?
    Paul

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author webbistro

    (@webbistro)

    Hello Paul,

    Modifying WordPress core is a bad practise. Every core update will rewrite changes, and every plugin can re-declare your changes.

    To modify attachment template you have to use print_media_templates action. EML v2.4 replaces WordPress default attachment template with its own attachment-grid-view, you can find its code in \enhanced-media-library-pro\core\taxonomies.php, line 1272.

    To re-write this code you have to add your own print_media_templates based on EML’s one.

    Best,
    -Nadia

    Thread Starter poppoll2

    (@poppoll2)

    @nadia,
    I know that changing the core is a bad practice.
    I managed to get the file name and id back, thanks to you.
    Many thanks!
    Paul

    This is the code just in case someone else has the same problem.

    
    /**
     *  my_eml_print_media_templates
     *
     *  @since    2.4
     *  @created  07/01/17
     */
    // remove the action 
    remove_action( 'print_media_templates', 'wpuxss_eml_print_media_templates', 10, 0 );
    
    add_action( 'print_media_templates', 'my_eml_print_media_templates', 10, 0 ); 
    if ( ! function_exists( 'my_eml_print_media_templates' ) ) {
    
        function my_eml_print_media_templates() {
    
            global $wp_version;
    
            if ( version_compare( $wp_version, '4.3', '<' ) ) {
    
                $remove_button = '<a class="close media-modal-icon" href="#" title="' . esc_attr__('Remove') . '"></a>';
    
                $deselect_button = '<a class="check" href="#" title="' . esc_attr__('Deselect') . '" tabindex="-1"><div class="media-modal-icon"></div></a>';
    
            }
            else {
    
                $remove_button = '<button type="button" class="button-link attachment-close media-modal-icon"><span class="screen-reader-text">' . __( 'Remove' ) . '</span></button>';
    
                $deselect_button = '<button type="button" class="button-link check" tabindex="-1"><span class="media-modal-icon"></span><span class="screen-reader-text">' . __( 'Deselect' ) . '</span></button>';
    
            } ?>
    
            <script type="text/html" id="tmpl-attachment-grid-view">
    
                <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
                    <div class="eml-attacment-inline-toolbar">
                        <# if ( data.can.save && data.buttons.edit ) { #>
                            <i class="eml-icon dashicons dashicons-edit edit" data-name="edit"></i>
                        <# } #>
                    </div>
                    <div class="thumbnail">
                        <# if ( data.uploading ) { #>
                            <div class="media-progress-bar"><div style="width: {{ data.percent }}%"></div></div>
                        <# } else if ( 'image' === data.type && data.sizes ) { #>
                            <div class="centered">
                                <img src="{{ data.size.url }}" draggable="false" alt="" />
                            </div>
    						<!-- mod voeg bestandsnaam EN ID toe aan tn in media bib. -->
    					<div class="filename">{{ data.filename}} - id:{{data.id}}</div>
    					
    					<!-- einde mod -->
                        <# } else { #>
                            <div class="centered">
                                <# if ( data.image && data.image.src && data.image.src !== data.icon ) { #>
                                    <img src="{{ data.image.src }}" class="thumbnail" draggable="false" />
                                <# } else { #>
                                    <img src="{{ data.icon }}" class="icon" draggable="false" />
                                <# } #>
                            </div>
                            <div class="filename">
                                <div>{{ data.filename }}</div>
                            </div>
                        <# } #>
                    </div>
                    <# if ( data.buttons.close ) { #>
                        <?php echo $remove_button; ?>
                    <# } #>
                </div>
                <# if ( data.buttons.check ) { #>
                    <?php echo $deselect_button; ?>
                <# } #>
                <#
                var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';
                if ( data.describe ) {
                    if ( 'image' === data.type ) { #>
                        <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption"
                            placeholder="<?php esc_attr_e('Caption this image&hellip;'); ?>" {{ maybeReadOnly }} />
                    <# } else { #>
                        <input type="text" value="{{ data.title }}" class="describe" data-setting="title"
                            <# if ( 'video' === data.type ) { #>
                                placeholder="<?php esc_attr_e('Describe this video&hellip;'); ?>"
                            <# } else if ( 'audio' === data.type ) { #>
                                placeholder="<?php esc_attr_e('Describe this audio file&hellip;'); ?>"
                            <# } else { #>
                                placeholder="<?php esc_attr_e('Describe this media file&hellip;'); ?>"
                            <# } #> {{ maybeReadOnly }} />
                    <# }
                } #>
            </script>
    
        <?php }
    }
    
    ?>
    
    Plugin Author webbistro

    (@webbistro)

    Hi Paul,

    Thank you for summarizing the code! Please don’t take my notes personally, there are a lot of people reading this forum with different levels of knowledge about WordPress.

    Best,
    -Nadia

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘File names’ is closed to new replies.