Tag Info

Hot answers tagged

3

One way to do it (which is probably evil) is to select the control by adding a block of javascript using the tr field of $form_fields: function set_image_data( $form_fields, $post ) { $form_fields['text_color'] = array( 'label' => 'Text Color', 'input' => 'text', 'value' => get_post_meta( $post->ID, '_text_color', ...


3

For the media library you can use the pre_get_posts hook targeting upload.php by means of $pagenow, a global variable, or even better, because globals are the devils child, by means of get_current_screen(). I'm assuming you want to target the media modal tab too - because targeting only one, but not the other, doesn't make much sense after all -, you can do ...


2

So thanks to @amritanshu and @wycks github's code, here is the solution for those in need to add a class with the media type to the attachment url before it gets inserted in the editor : if ( ! function_exists( 'epc_add_class_pdf' ) ) : function epc_add_class_pdf( $html, $id ) { $attachment = get_post( $id ); $mime_type = ...


1

Here's a shorter way to do it (PHP 5.4+): add_filter( 'media_send_to_editor', function( $html, $send_id, $attachment ) { $class = wp_check_filetype( $attachment['url'] )['ext']; return str_ireplace( '<a href', sprintf( '<a class="%s" href',$class ? $class : 'unknown' ), $html ); }, 10, 3 ); where we get the attachment's info from the third input ...


1

You can try adding the input file field once and using then using jQuery to add more fields when clicking add more. Here are the steps Register your setting using register_setting function Create Menu using add_menu_page. This also requires a calback function Add the thickbox and media-upload script using wp_enqueue_script and wp_enqueue_style Use the ...


1

This is not the answer but just the hint. media_send_to_editor should be the hook that should help you. Not sure how but came across this while searching for my problem I would have commented but still 4 points short, so unable to comment All the best


1

I can only take a guess at this. Is the image you want to change a background image (using CSS)? - if you goto the page, use your web inspector tool. You should then be able to see where image url is coming from.



Only top voted, non community-wiki answers of a minimum length are eligible