Tagged: image
-
AuthorPosts
-
July 16, 2013 at 4:49 pm #26290
I am trying to generate new image sizes in a child theme.
I have added this to the child theme functions.php file:
$avia_config['imgSize']['product-thumb'] = array('width'=>250, 'height'=>250); // smaller product images
$avia_config['slectableImgSize'] = array(
'product-thumb' => __('Product Thumb','avia_framework'),
);After I run regenerate thumbnails, I do see that the new image is on FTP. But when I am using the builder and use the image element I do not see the new size available in the “Attachment Display Settings” dropdown.
Am I missing something to add this to that dropdown?
July 17, 2013 at 7:22 am #129949Hey!
Try to wrap your code into a function and use the init hook to add your thumbnail size to the avia_config array: https://kriesi.at/support/topic/override-the-global-avia_config-within-child-functionsphp
Best regards,
Peter
July 17, 2013 at 3:15 pm #129950Hey Peter,
Thanks for the link. In doing how you suggested it removes other items in the drop down Display Settings dropdown.
Before the code I have 9 choices:
Thumbnail – 80 × 80
Medium – 300 × 300
Full Size – 900 × 900
Square – 180 × 180
Featured – 900 × 430
Portfolio – 495 × 400
Gallery – 710 × 575
Entry with Sidebar – 710 × 270
Entry without Sidebar – 900 × 360
Then I wrapped the code above in a function:
// Add Custom sizes for Products
function avia_change_image_size_array() {
global $avia_config;
$avia_config['imgSize']['product-thumb'] = array('width'=>250, 'height'=>250); // small preview pics eg sidebar news
$avia_config['slectableImgSize'] = array(
'product-thumb' => __('250 x 250','avia_framework'),
);
}
add_action( 'init', 'avia_change_image_size_array');Now I only get 3 choices:
Thumbnail – 80 × 80
Medium – 300 × 300
Full Size – 900 × 900
250 x 250 – 250 × 250
Thoughts on why the rest of the list is not appearing?
July 17, 2013 at 3:25 pm #129951Hi kcharity,
Its replacing the contents of the array so you need to add in all of them again in your child theme function.
Regards,
Devin
July 17, 2013 at 8:58 pm #129952Ok thanks for that Devin. Would it be possible for the future to add a hook so just defined new ones are added?
July 18, 2013 at 3:19 am #129953I’ll add it as a request to our github.
-
AuthorPosts
- The topic ‘Generate new image sizes in child theme’ is closed to new replies.