renaming an image automatically everywhere else (posts and pages)

I did the same thing few days back. I took the post slug as image name for SEO purpose. I created a function to create/move images to a particular folder depending on the slug and input image url. Here is look of my function- function tb_get_image($image_ext_url,$slug,$upload_folder=””,$title=””){ $uri = WP_CONTENT_DIR.”/uploads/”.$upload_folder; $folder = WP_CONTENT_URL.”/uploads/”.$upload_folder; if(!file_exists($uri)){ $oldmask = … Read more

2 image size for post

WP image sizes apply to all images – there’s no way to tell WP, “only generate rectangular sizes when I upload a rectangular image; and only generate square sizes when I upload a square image.” So, you need to add (or customize an existing) image size for each scenario.

Accessing an image folder inside public web directory

For directory (folder), only read is not enough. You need to set execute also. Because for directory, execute means you can enter the directory. Files need read permission & directory needs read & execute permission. So the directory permission should be: 0555. However, image files inside that directory should be just read, in numeric form: … Read more

What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?

Calling the_content from within attachment.php will bring you the Attachment Description. Put the code below on your page and see what you can get from within attachment.php file: while ( have_posts() ) : the_post(); /** * @link https://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata#Related */ $data = array( get_the_ID(), // Gets att ID. get_permalink(), // Gets att page link. get_the_title(), // … Read more

Auto delete attachments that are older than x days

Are you really sure you want to do this? What about all of the posts that these “old” attachments are used in? For attachments that are used for things like “featured image”, WP will take of that for you. However, for uses of an attachment in post_content, e.g. <img src=”https://wordpress.stackexchange.com/questions/258966/img_attachment_url” /> <a href=”pdf_attachment_url”>download PDF</a> you’ll … Read more