Show media url immediately after upload in media uploader

Here’s a heinous hack that replaces the title of uploaded images with the url (constructed by chopping the “-150×150” affix from the pinkynail): function wpse156087_admin_footer_media_new_php() { ?> <script type=”text/javascript”> jQuery(document).ready(function() { (function ($) { uploader.bind(‘UploadComplete’, function() { setTimeout(function() { $(‘#media-items .media-item’).each(function () { var img_src = $(‘img’, this).prop(‘src’); if (img_src.indexOf(‘/wp-content/uploads/’) > 0) { $(‘.filename.new .title’, … Read more

uploading images to specified directories

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 folder structure.

How to display featured image without it appearing in post?

You can set the featured image on the post. That featured image will not be on the post content. If it’s showing on the post it’s because your template is calling has_thumbnail() on the single.php or content-single.php. If you need more help, please past the single.php or content-single.php code, or say which theme you are … Read more

Override img class in gallery

You should add !important to your styles in order to override it. Better way to do this is to copy the .img-responsive styles from the Bootstrap CSS file and apply these styles to your desired HTML element instead of adding a class using PHP. img.attachment-large { display: block; max-width: 100%; height: auto; } Or target … Read more

Display attachment resolution size

The wp_get_attachment_img_src( $attachment_id ) function returns an array consisting of: The URL to the img width height To get the actual attachment/thumbnail/featured image ID, you want to use $att_ID = get_post_thumbnail_id( get_the_ID() ); in the loop. Outside the loop, you would have to get the Post ID somehow to feed it in as get_the_ID() refers … Read more

Set the background to a default image if there isn’t a specified “featured image”

I found the solution from a WordPress forum and this is what they used. Works perfect <?php if (has_post_thumbnail( $post->ID ) ): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ” ); $image = $image[0]; ?> <?php else : $image = get_bloginfo(‘stylesheet_directory’) . ‘/lib/images/home1-1024×681.jpg’; ?> <?php endif; ?> <section id=”halfpro” style=”background-image: url(‘<?php echo $image; ?>’)” … Read more

Extract image url associated to a category

I found what I needed: $category = get_category( get_query_var( ‘cat’ ) ); $cat_id = $category->cat_ID; $images = get_posts( array(‘post_type’ => ‘attachment’, ‘category__in’ => $cat_id)); if ( !empty($images) ) { foreach ( $images as $image ) { $image_url = $image->guid; } } else{ $image_url=””; } First I got the category, and current category ID I’m in. … Read more