Hot answers tagged

2

You can check mime type of uploaded image before upload to media. Add mimeTypes in $allowmimeType which you want to allow. then check uploaded files mimetype $fileMimeType. If not found in allowed mimetype then return false. // Insert Attachment function insert_attachment($file_handler, $post_id, $setthumb='false') { if ($_FILES[$file_handler]['error'] ...


2

If you're trying to link the image to the page in the post editor you can click on the image and then click the link icon to set the target. You can do the same thing in HTML (in the editor in source view), in a plugin, or in a theme like this: <a href="/link/to/your/page"> <img src="/link/to/your/image" /> </a>


1

Take a look at wp_upload_dir here https://developer.wordpress.org/reference/functions/wp_upload_dir/ $upload_dir = wp_upload_dir(); var_dump( $upload_dir ); /* $upload_dir will comprise of the following return values: 'path' - (string) Base directory and subdirectory or full path to upload directory. 'url' - (string) Base URL and subdirectory or ...


Only top voted, non community-wiki answers of a minimum length are eligible