Is there a way to define a default caption to all uploaded images

There’s really no documentation for it yet, but you’ll probably be able to do it hooking to the attachment_fields_to_save filter and inserting the default caption there. From the Codex: attachment_fields_to_save applied to fields associated with an attachment prior to saving them in the database. Called in the media_upload_form_handler function. Filter function arguments: an array of … Read more

How to disable “insert into post” only when selecting the Featured Image?

You can do this via, add_filter(‘image_send_to_editor’, ‘restrict_images’); function restrict_images($html){ return false; } …now consider the above function primitive, because it will restrict images for all post types. We can modify that on a post_type by post_type basis like so, add_filter(‘image_send_to_editor’, ‘restrict_images’); function restrict_images($html){ // check if its the admin trying to insert image, if so, … Read more

How to rename an image attachment filename using php

Let’s go and see. If I take arbitrary attachment in my dev install and dump its post object and custom fields I get the following: object WP_Post (24) { public ID -> integer 1687 public post_author -> string (1) “1” public post_date -> string (19) “2013-09-18 14:37:07” public post_date_gmt -> string (19) “2013-09-18 21:37:07” public … Read more

Dynamically add titles to post images if they are empty

You can try the following test plugin, that uses the domDocument class, to see how it works on your HTML. It assumes PHP 5.4+ with LibXML 2.7.8+. <?php /** * Plugin Name: Add Missing Image Title Attributes * Description: For posts in the main loop (Assumes PHP 5.4+ with LibXML 2.7.8+) * Plugin URI: http://wordpress.stackexchange.com/a/188560/26350 … Read more

Adding HTML within an image title attribute

First of all i’d recommend you stop using title attribute for html container purpose: Image title (and the element name speaks for itself) should provide additional information and follow the rules of the regular title: it should be relevant, short, catchy, and concise (a title “offers advisory information about the element for which it is … Read more

WP 4.4 aspect ratio with responsive image

You shouldn’t. srcset is used for when you want to optimise the quality for different devices by serving different sizes of the same image. If you want to serve different crops, you should be using the picture element instead. For example, if the intention of your image sizes is to serve a ‘small’ version to … Read more

Downsizing Many Large Images Attached to Posts, in Bulk?

Great question! WordPress lacks some of the higher level imaging management features that would make it file maintenance like you need so much easier. The core WordPress team has been threatening to add enhance image features for many versions; eventually they might actually do it! Until then you’ll have to use a patchwork of plugins … Read more

hide/protect original full-size images

I was looking for a way to do this and found this page… then I thought of putting this in a .htaccess file in the WordPress uploads folder and it works for me so far… any good? <FilesMatch “\.jpg$”> order allow,deny deny from all </FilesMatch> <FilesMatch “-[0-9]+x[0-9]+\.jpg$”> order allow,deny allow from all </FilesMatch> The first … Read more

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