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

Unable to check if image uploaded by wp_image_editor exists using file_exists function

When I used your exact code on a local test site I was unable to save the resized image. This is because you’re passing a URL to wp_get_image_editor() instead of a path. You’re also passing a URL to pathinfo(), which also requires a path. $pathinfo = pathinfo( $uploaded[‘url’] ); $image = wp_get_image_editor( $uploaded[‘url’] ); The … Read more

Upload file without attaching it to a POST

The $post_id argument for media_handle_upload is used to set the column post_parent for attachment post. Posts without any parent have 0 as post parent, not null. So, use 0 as argument and it will work. If you read Codex page linked above it states: … If you don’t want this media attached to a specific … Read more

What types of files can I upload with the WordPress Uploader?

From http://codex.wordpress.org/Uploading_Files : WordPress supports uploading the following file types: Images .jpg .jpeg .png .gif Documents .pdf (Portable Document Format; Adobe Acrobat) .doc, .docx (Microsoft Word Document) .ppt, .pptx, .pps, .ppsx (Microsoft PowerPoint Presentation) .odt (OpenDocument Text Document) .xls, .xlsx (Microsoft Excel Document) Audio .mp3 .m4a .ogg .wav Video .mp4, .m4v (MPEG-4) .mov (QuickTime) .wmv … Read more