Get total number of pixels, size in megapixels and aspect ratio based on image width and height?

Sure – php can definitely handle simple math like this. All you’d have to do is reference the numbers coming back from the wp_get_attachment_image_src call: <?php if ( has_post_thumbnail()) { $full_image_info = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), ‘full’); $img_h = $full_image_info[1]; $img_w = $full_image_info[2]; $total_pixels = $img_w * $img_h ; $megapixels = round($total_pixels) /* see http://at2.php.net/manual/en/function.round.php — they … Read more

alt, title tags not showing

It actually depends upon how the image is shown in the template. If it is shown using a function like the_post_thumbnail() which returns complete html string to show image with alt then there should be no problem but if image is shown by only fetching URL then it depends how it is displayed . For … Read more

Wrap all post images inside a div element

Try using PHP’s regular expression find/replace function—preg_replace()—in a filter on the the_content hook. function breezer_addDivToImage( $content ) { // A regular expression of what to look for. $pattern = ‘/(<img([^>]*)>)/i’; // What to replace it with. $1 refers to the content in the first ‘capture group’, in parentheses above $replacement=”<div class=”myphoto”>$1</div>”; // run preg_replace() on … Read more

Rename attachments during upload

You can try to replace $arr[‘name’] = $post_slug . ‘-‘ . $random_number . ‘.jpg’; with $arr[‘name’] = $post_slug . ‘-‘ . $arr[‘name’]; to get the file format [post_slug]-[original_filename].ext. Update: Here is an example of the $arr structure for an image with the filename car.png : Array ( [name] => car.png [type] => image/png [tmp_name] => … Read more

get_children – wp_get_attachment_image

You could Limit the output to 1 like this but this is not a solution, only a workaround: $args = array(‘post_parent’ => get_the_ID(), ‘numberposts’ => 1, ‘order’ => ‘ASC’, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’ ); $images = get_children( $args ); if ($images) { foreach ($images as $image) { echo wp_get_attachment_image($image->ID, ‘full’); } } Have … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)