Title: Adding img width=&quot;&quot; height=&quot;&quot; via Function.php
Last modified: August 22, 2016

---

# Adding img width="" height="" via Function.php

 *  [CreativeWP](https://wordpress.org/support/users/creativewp/)
 * (@creativewp)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/adding-img-width-height-via-functionphp/)
 * Hi, I am working on a site, that needs to have the images width=”” height=”” 
   added in a certain class. The site does not have this on images,
 * So it is like this now,
 * <div class=”myclass”>
    <img src=”path” alt=”title”> </div>
 * But I need it like this,
 * <img width=”” height=”” src=”” alt=””>
 * It is a a high end theme, responsive with a child theme.
 * So I would like to see, a code in the function.php that will assign this to the
   images in certain class, or classes. I am hoping to have about 4 different sections
   with different classes. So may be feature will be 300×400 pixels, the second 
   feature images will be 250×250.
 * And so on, can that be done?
 * Thanks,

Viewing 1 replies (of 1 total)

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [11 years, 4 months ago](https://wordpress.org/support/topic/adding-img-width-height-via-functionphp/#post-5765629)
 * You can create your own thumbnails when you upload images (will require a reupload
   of images or plugin that does this): [http://codex.wordpress.org/Function_Reference/add_image_size](http://codex.wordpress.org/Function_Reference/add_image_size)
 * For featured images you can call “the_post_thumbnail” along with the custom image
   size you created, e.g.:
 *     ```
       if ( has_post_thumbnail() ) {
       	the_post_thumbnail( 'childtheme-large' );
       }
       ```
   
 * See if you have the image attributes then

Viewing 1 replies (of 1 total)

The topic ‘Adding img width="" height="" via Function.php’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/adding-img-width-height-via-functionphp/#post-5765629)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
