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

add_image_size is scaling, even though crop is set to true

from your question i under that you want fixed size cropped images when you upload image, why don’t you use wp_get_image_editor. I used it in my project where i wanted cropped images of fixed size so i did this code. $path = $newPath[‘basedir’].’/newImgas/’; $cropfile = uniqid() . ‘.png’; $cropfilename = $path.$cropfile; $cropImage = home_url(). ‘/wp-content/uploads/newImgas/’.$cropfile; … 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

Can I load posts via Ajax?

Absolutely! There are a number of themes on the market that do load posts via AJAX. Take a look at any of them to get an idea of how they work. A particularly good example is K2 – K2 loads entire pages of posts via AJAX if you click on the previous posts link. To … Read more