Cropping an image before inserting into a post

I think you are good, but you don’t need to use other functions. You have all in File: wp-includes/media.php For instance, you may _wp_get_image_size_from_meta to get the image dimensions, so you don’t need to use something like this: $size = getimagesize($file); $width = $size[0]; $height = $size[1]; $mime = $size[‘mime’]; To get the image dimensions … Read more

Allowing post attachments without allowing to insert in text

One way to do this would be to simply hide the upload/insert media button: and, then add featured image support for your themes posts, so a user can still attach images to the post. Hide upload/insert media button for your theme in: functions.php: function hideUploadInsert($hook) { if($hook != ‘post.php’ AND $hook != ‘post-new.php’) return; // … Read more

Using Taxonomy Image code with my get_categories code

No luck by using plugin provided functions as it gets it’s id by $obj = get_queried_object(); To get the image I use this code snippet: $associations = taxonomy_image_plugin_get_associations(); $tt_id = absint( $taxonomy_term->term_id ); if ( array_key_exists( $tt_id, $associations ) ) { $image_id = absint( $associations[ $tt_id ] ); } $image = wp_get_attachment_image( $image_id, ‘thumbnail’ );

add data-attribute to all images inside the_content()

You will need to take a look at the image_send_to_editor filter. This will not update existing records but it if you get it working it will apply to each newly inserted image. very basic filter: function give_linked_images_class($html, $id, $caption, $title, $align, $url, $size, $alt=”” ){ $html; //contains the string you need to edit, you might … Read more

How can i alter the amount of different images sizes being stored?

Additional image sizes for uploaded images are created by wp_generate_attachment_metadata() after the file has been uploaded. An array of available sizes is populated using get_intermediate_image_sizes() (thumbnail, medium, large + custom sizes) which is later used to create the images. Both of the above functions have filters for overriding the sizes available to WordPress during this … Read more

Wrong domain in uploads folder

I will allow myself to expand on Ricks answer as there are a few ways to change old domain to new domain and each might be helpful depending on your situation. 1) use the Better Search and Replace plugin https://wordpress.org/plugins/better-search-replace/ plugin as suggested in the answer above. 2) use Database Search and Replace script https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ … Read more

Remove rel=”attachment wp-att-XX”

You can remove it right before post is printed to the screen by stripping it out from content. But remember it still will meddle in Editor. <?php function my_remove_rel_attr($content) { return preg_replace(‘/\s+rel=”attachment wp-att-[0-9]+”/i’, ”, $content); } add_filter(‘the_content’, ‘my_remove_rel_attr’);

Why won’t these imported images show up?

I am assuming that WP takes the additional parameters at the end of the file name to automatically resize the image… WordPress adds those suffixes when it creates the images, which is typically done on image upload. Those images should be on the server. By default (and if I am not mistaken), WordPress does not … Read more

How to output placeholder image if no featured image set?

I think that you’re adding the code inside the loop of index.php or blog template file. You might be try this kind of things: if ( class_exists( ‘MultiPostThumbnails’ ) && ( MultiPostThumbnails::has_post_thumbnail( get_post_type(), ‘header-image’ , get_the_ID() ) ) ) { MultiPostThumbnails::the_post_thumbnail(get_post_type(), ‘header-image’, NULL, ‘header-image-full’, array(‘class’ => “custom-header-image”) ); } else { $image = get_template_directory_uri() .’/assets/img/placeholders/placeholder.png’; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)