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
@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…'); ?>" {{ 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…'); ?>"
<# } else if ( 'audio' === data.type ) { #>
placeholder="<?php esc_attr_e('Describe this audio file…'); ?>"
<# } else { #>
placeholder="<?php esc_attr_e('Describe this media file…'); ?>"
<# } #> {{ maybeReadOnly }} />
<# }
} #>
</script>
<?php }
}
?>
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