Tag Info

New answers tagged

1

Wordpress resizes the images when you upload them based on the settings in the functions file in your active theme. If you switch themes it might resize everything again leading to the many sizes, butI'm not sure if that is why you have so many strange sizes. This is the wordpress page related to the deprecated image function, and this is the newer ...


0

You can do something like this in your functions file. add_image_size( 'category-thumb', 300 ); // 300 pixels wide (and unlimited height) add_image_size( 'homepage-thumb', 220, 180, true ); // (cropped) Then you can do something like this to give your custom size a certain name in the Admin area. add_filter( 'image_size_names_choose', ...


0

This has something to do with the HTML of a media object. I copy/pasted code from another image imported from the media gallery and it worked. Use this function to insert the content: http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setContent tinyMCE.activeEditor.setContent('<span>some</span> html');


2

If you want to use get_attached_media(), you can try for example: if( has_post_thumbnail() ) { the_post_thumbnail(); } else { $imgs = get_attached_media( 'image' ); if( count( $imgs ) > 0 ) { $img = array_shift( $imgs ); echo wp_get_attachment_image( $img->ID, 'thumbnail' ); } } to display one of the attached ...


2

In your handler, if you set 'error', the error message will be displayed and will cancel the upload add_filter('wp_handle_upload_prefilter', 'custom_upload_filter' ); function custom_upload_filter( $file ){ $image_info = getimagesize($file['tmp_name']); $image_width = $image_info[0]; $image_height = $image_info[1]; if($image_with != 800 ...


0

By Javascript you can pop-up the media and on select you can update the image URL to the textbox. Below is the code. var custom_uploader; jQuery('<Should-be-a-button-selector>').click(function(e) { e.preventDefault(); //If the uploader object has already been created, reopen the dialog if (custom_uploader) { custom_uploader.open(); ...


0

The UCC SSL Certificate is used to secure multiple domains like www.example.com, www. example.net, www.example.co.uk etc. and if you want to secure your subdomains like shop.example.com, distributors.example.com and careers.example.com then you should try Unified Communication Wildcard Certificate instead of UCC SSL Certificate because it protects both ...


0

A hacky way to do it is to do a string replace on the tmpl-attachment-details template: // See wp_print_media_templates() in "wp-includes/media-template.php" function wpse157297_print_media_templates() { $my_link = '<a class="my_link-attachment" href="my_link.php?url={{ data.url }}" target="_blank">' . __( 'My Link' ) . '</a>'; $nonimage ...


1

Attempting a somewhat canonical (or at least bountiful) answer, this is the javascript for wpse142997.js in the child template directory: jQuery( document ).ready(function() { ( function( $ ) { var media = wp.media, l10n = media.view.l10n = typeof _wpMediaViewsL10n === 'undefined' ? {} : _wpMediaViewsL10n, attachments = ...


0

This might be perfect solution for you: http://wordpress.org/plugins/custom-upload-dir/ With that plugin you can have upload folder structure as you wish: "uploads/$image_type./.$client./.$post_title./" or uploads/category/subcategory/post_title/ Or anything you like, you can combine post title, category, post author, post date and many more in your ...


1

You just have to call destroy method on the attachment model. This will both remove the attachment from the Media Library view, and send an ajax call to the backend to delete the attachment in the database and all linked files in uploads directory. You do not need to convert the attachment to JSON to get the id : you can directly manipulate the Backbone ...


1

The answer is there is no damn hook for the edit button. It's just a bunch of JS contained within wp-includes/js/tinymce/plugins/wpeditimage/plugin.js. I've included the barebones of what you need below. Key points: a. Clicking an element with a data-wp-imgselect attribute will open the image edit dialogue. You need to change that to something else if you ...


0

A bit of background to make sure we are in sync: Uploading an image means that you create a new post (of type attachment) in WordPress database and you create a few image files in WordPress file system (one file per size) Attaching to a post means that you mark the (hereabove) attachment post as child of this post. Meaning that an attachment can be only ...


1

wordpress sucks in keeping media<=>content relationships. Part of the problem is that by default all media are public once they are uploaded and you have no way to know where are they are being used. Just because an image is not referenced anymore in its original post doesn't mean that it is not referenced at any other place (sidebar widget?) or maybe by ...


0

The only way to do it is using a query filter I think function wpse156319_posts_where( $where, $query ) { global $wpdb; $where .= $wpdb->prepare( ' AND (' . $wpdb->posts . '.post_parent = %s OR ' . $wpdb->posts . '.post_author = %s)', $_POST['id'], get_current_user_id() ); return $where; } which you just add in the ...


1

Have you tried to use get_children() function? Edit: All media attached to any post is treated as children of it. The function wp_get_attachment_image() will only return images. With the function get_children() you'll be able to get all the media, images or anything else. In the above link, you can find some examples.



Top 50 recent answers are included