Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Created March 6, 2017 10:34
Show Gist options
  • Save hsleonis/b0a8cf8741776c6f592a8643b0a8e8d2 to your computer and use it in GitHub Desktop.
Save hsleonis/b0a8cf8741776c6f592a8643b0a8e8d2 to your computer and use it in GitHub Desktop.
Add custom fields in attachment page
<?php
add_action( 'attachment_fields_to_edit', array($this, 'tmx_attachment_fields_to_edit'), 10, 2 );
public function tmx_attachment_fields_to_edit( $form_fields, $post ){
// Apply only in image attachment pages
if( $post->post_mime_type == 'image/jpeg' || $post->post_mime_type == 'image/jpg' || $post->post_mime_type == 'image/png' ){
$form_fields['tmx-apply-filter-sbutton'] = array(
'label' => __('Add Image effects', 'themeaxe'),
'input' => 'html',
'helps' => __('Apply filter effects to image.', 'themeaxe'),
'html' => '<a class="button easy-image-filters-button" href="'.admin_url('upload.php?page=easy-image-filters-page').'&attachment_id='.$post->ID.'">'.__('Add','themeaxe').'</a>',
);
}
return $form_fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment