Rename attachments during upload

You can try to replace $arr[‘name’] = $post_slug . ‘-‘ . $random_number . ‘.jpg’; with $arr[‘name’] = $post_slug . ‘-‘ . $arr[‘name’]; to get the file format [post_slug]-[original_filename].ext. Update: Here is an example of the $arr structure for an image with the filename car.png : Array ( [name] => car.png [type] => image/png [tmp_name] => … Read more

get_children – wp_get_attachment_image

You could Limit the output to 1 like this but this is not a solution, only a workaround: $args = array(‘post_parent’ => get_the_ID(), ‘numberposts’ => 1, ‘order’ => ‘ASC’, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’ ); $images = get_children( $args ); if ($images) { foreach ($images as $image) { echo wp_get_attachment_image($image->ID, ‘full’); } } Have … Read more

Adjusting caption below single post image

Override The Image Caption With Image Title And Description Here’s a way to override the caption with the image title and image description, with a demo plugin. Let’s assume we have uploaded this image: Then we insert it into the editor with the following: Before: Without our plugin activated it will display as: After: With … Read more

Add visual editor to Media Edit Screen

This function added to functions.php does exactly that: // Enables Editor in Media edit screen. function add_editor_support_for_attachments($settings) { if( get_post_type() == ‘attachment’){ $quicktags_settings = array( ‘buttons’ => ‘strong,em,link,block,del,ins,ul,ol,li,code,close’ ); $settings = array( ‘wpautop’ => true, ‘textarea_name’ => ‘content’, ‘textarea_rows’ => 10, ‘media_buttons’ => false, ‘tinymce’ => true, ‘quicktags’ => $quicktags_settings, ); return $settings; } } … Read more

Featured Images on Front Page

Two categories should do the trick. Featured posts – This category should be applied to posts that you want to show on your home page, with that images grid. You can limit the number of posts (so only the, for example, 6 newest ones would appear) and select the featured image for them on each … Read more

Media sizes aren’t being created – server config?

It looks like “Easy Apache” handles both Apache and PHP. Only a guess, but you have recompiled Apache/PHP without the needed image libraries– either GD or ImageMagick. Without those, the server cannot physically resize images. You can use a phpinfo() script to see if the libraries are present. If not, you will need to recompile– … Read more

Hook for saving an image after editing

wp_save_image_editor_file filter fires after. add_filter( ‘wp_save_image_editor_file’, ‘custom_wp_save_image_editor_file’, 10, 5 ); function custom_wp_save_image_editor_file( $saved, $filename, $image, $mime_type, $post_id ){ //Your logic here return $saved; }