How to insert images into posts without using Add Media dialog

The WordPress default media management system is pretty good and far better than what you want. However, you can use the Advanced Custom Fields to add image upload boxes in your post editor page. Once the image is uploaded, you can display it in the editor using a shortcode [acf field=”{$field_name}”]. Check out ACF Documentation … Read more

Rename files on upload

no need to use a custom table, use an option, and the add_attachment hook: function wpa59168_rename_attachment( $post_ID ) { $post = get_post( $post_ID ); $file = get_attached_file( $post_ID ); $path = pathinfo( $file ); $count = get_option( ‘wpa59168_counter’, 1 ); // change to $new_name = $count; if you want just the count as filename $new_name … Read more

Maintaining image color and quality when uploading using custom sizes

Use the jpeg_quality and wp_editor_set_quality filters to set the quality of resized images: add_filter( ‘wp_editor_set_quality’, ‘wpse246186_image_quality’ ); add_filter( ‘jpeg_quality’, ‘wpse246186_image_quality’ ); function wpse246186_image_quality( $quality ) { return 100; // 0 – 100% quality } I have not been able to reproduce the issue reported; the original PNG image looks the same as the thumbnails. Tested … Read more

Featured image shortcode

Register the shortcode, ideally in a plugin or functions.php if you have to. add_shortcode(‘thumbnail’, ‘thumbnail_in_content’); function thumbnail_in_content($atts) { global $post; return get_the_post_thumbnail($post->ID); } Add the shortcode to you post content. [thumbnail] If you want more features, see this post or the pastebin. ADDING CAPTIONS AND LINKS add_shortcode(‘thumbnail’, ‘thumbnail_with_caption_shortcode’); function thumbnail_with_caption_shortcode($atts) { global $post; // Image … Read more

Separate Media Library for each user

Built in features The Media Library has major updates with the upcoming version. You can see the changes in the slides by Daryl Koopersmith here. You can read the announcement and discussion on “Make”. Your request for “tags/categories” is already built into 3.5. Note The difference between themes and plugins is pretty easy: Display vs. … Read more

How to display a page’s featured image?

Adapted from this thread on the WP forums: <?php if (has_post_thumbnail( $post->ID ) ): ?> <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), ‘single-post-thumbnail’); ?> <style> #banner-id { background-image: url(‘<?php echo $image[0]; ?>’); } </style> <?php endif; ?> Add this to your single page template, after the_post(). I’d reccommend having a default header image so that if the page … Read more

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