Frontend Post – Allow Only Image File Upload

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’] !== UPLOAD_ERR_OK){ return __return_false(); } # uploaded file type … Read more

Best option for photo/gallery handling?

You can keep your whole site together, i.e. texts and images, the main suggestion: just don’t mix up large image/galleries with your text stream, this will indeed slow down your site loading. While most bloggers want display their pictures at any cost, most visitors just want read a specific text, then this approach become annoying … Read more

How to change image url?

Go into your WordPress Dashboard > Settings > Media and then untick the option that says Organize my folders into Month and Year based folders This will make it look like: http://example.com/wp-content/uploads/imagename.jpg Then to take it further you need to update you config.php file and add in either this line: define( ‘UPLOADS’, ‘image/’.’files’ ); This … Read more

get custom image size

If you know the image’s ID : wp_get_attachment_image( $image->ID, array(200, 112) ); returns an HTML img element or empty string on failure. The entire code could be something like : <a href=”https://wordpress.stackexchange.com/questions/170690/<?= get_attachment_link(“5435′ ); ?>”> <?= wp_get_attachment_image( ‘5435’, array(200, 112) ); ?> </a>

Display an image instead of tag name?

A clean and semantic way to do it would be with CSS. First, the PHP: <div class=”entry-meta”> <span class=”term-links”> <?php foreach ( get_the_terms( $post->ID, ‘region’) as $term ) : ?> <a href=”https://wordpress.stackexchange.com/questions/233793/<?php echo esc_url( get_term_link( $term->term_id ) ) ?>”>Region: <span class=”<?php echo $term->slug ?>”><?php echo $term->name ?></span></a> <?php endforeach; ?> </span> </div> Next, the CSS: … Read more