soflyy / oxygen-bugs-and-features

Bug Reports & Feature Requests for Oxygen
https://oxygenbuilder.com/
316 stars 30 forks source link

Custom image sizes support in Oxygen editor #675

Open srikat opened 4 years ago

srikat commented 4 years ago

Custom image sizes (registered using add_image_size) do not appear in the Size dropdown for images.

screenshot-1

screenshot-1

Please consider fixing/adding this.

It would also be good if custom image sizes are read and shown in all other places where image size can be selected. Ex.: https://github.com/soflyy/oxygen-bugs-and-features/issues/433.

adrien-robert commented 4 years ago

+1

WeatherfordDigital commented 4 years ago

Please

vicento commented 4 years ago

+1

PeterCarsten commented 4 years ago

Would be helpfull

yasien-s commented 4 years ago

👍🏼

jornmo commented 4 years ago

Yes thank you!

cliffhewson commented 4 years ago

+1 Seems pretty fundamental!

c001os commented 4 years ago

+1 would be great!

mo-mono commented 4 years ago

+1 👌🏼

davidlower8 commented 4 years ago

Yes please. +1.

websmx commented 4 years ago

Please, please!

sunnyt7 commented 4 years ago

+1

bpages383 commented 4 years ago

+1 it would be great

wplit commented 4 years ago

This is already working, but the only sizes that appear in the dropdown are specific to the image currently selected. So usually regenerating thumbnails after creating the custom image size then refreshing Oxygen will make them appear in the dropdown (if that image has this size available)

oxygen-image-size-dropdown

I just mentioned at the bottom of this post..

https://wpdevdesign.com/using-responsive-srcset-images-custom-image-sizes-in-oxygen/

srikat commented 4 years ago

Custom image sizes should also be available to pick in other places.

https://github.com/soflyy/oxygen-bugs-and-features/issues/433

PaRoxUs commented 3 years ago

+1

clockwood commented 3 years ago

+1

derSebastian commented 3 years ago

+1

Jehu commented 3 years ago

What the....!!! This is still an open Bug?

yoshi-12321 commented 3 years ago

+1

kevingeary commented 3 years ago

+1

ukdesignservices commented 3 years ago

+1

norman-pixelkings commented 3 years ago

+1

V0IDNIL commented 3 years ago

+1

norman-pixelkings commented 3 years ago

+1

heavestudio commented 3 years ago

+1000

LauGau commented 3 years ago

+1

shock2d commented 3 years ago

This is must for speed workflow

adrien-robert commented 3 years ago

+1

RicsBits commented 3 years ago

++

acicovic commented 3 years ago

To all +1 posters: Also click on the thumbs up icon in the first post to make this go higher when sorting by thumbs up.

Also, check #433 which is related.

lucianahanan commented 3 years ago

+1

gerogr commented 3 years ago

+1

fifle commented 3 years ago

+1. This feature is needed a lot :)

d-packs commented 3 years ago

This is already working, but the only sizes that appear in the dropdown are specific to the image currently selected. So usually regenerating thumbnails after creating the custom image size then refreshing Oxygen will make them appear in the dropdown (if that image has this size available)

This is not correct in my experience. For some reason the image sizes are note populated, even after regenerating thumbs. This feature does not work.

jevgen commented 3 years ago

+1. Needed a lot.

d-packs commented 3 years ago

This is already working, but the only sizes that appear in the dropdown are specific to the image currently selected.

Even if it would have worked like this, this is not the correct behavior. The drop-down should not be limited to the currently selected image's sizes. Images and their sizes are in continuous flux during development. If an image size has been registered with add_image_size it should appear in the dropdown.

jevgen commented 3 years ago

Thank you @d-packs , it really does. I added custom image size declaration to custom functionality plugin and it worked. The only hinder was to find out an appropriate way to regenerate thumbnails. And built in WP-CLI support for that helped a lot. WP-CLI can selectively regenerate thumbnails for array of IDs.

vadimbk commented 3 years ago

Add this to CodeSnippets and activate

add_theme_support( 'post-thumbnails' );
add_image_size( 'image-480', 480, 9999 );
add_image_size( 'image-640', 640, 9999 );
add_image_size( 'image-720', 720, 9999 );
add_image_size( 'image-960', 960, 9999 );
add_image_size( 'image-1168', 1168, 9999 );
add_image_size( 'image-1440', 1440, 9999 );
add_image_size( 'image-1920', 1920, 9999 );

add_filter( 'image_size_names_choose', 'custom_image_sizes' );

function custom_image_sizes( $size_names ) {
$new_sizes = array(
'image-480' => __( 'Size480', 'text-domain' ),
'image-640' => __( 'Size640', 'text-domain' ),
'image-720' => __( 'Size720', 'text-domain' ),
'image-960' => __( 'Size960', 'text-domain' ),
'image-1160' => __( 'Size1160', 'text-domain' ),
'image-1440' => __( 'Size1440', 'text-domain' ),
'image-1920' => __( 'Size1920', 'text-domain' )
);
return array_merge( $size_names, $new_sizes );
}

How to use it in repeaters see next comment

vadimbk commented 3 years ago

To use proper file size in dynamic data in repeater insert a function in code snippets /**

return wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), $size)[0]; }

in data dialog select Advanced (php function return value)

insert 2 parameters: Function name right_image_filename Name of registered size image-489

and voila Works like a charm

nathanbitcheno commented 3 years ago

To use proper file size in dynamic data in repeater insert a function in code snippets /**

  • Returns the file name of right size of image
  • @param string $size registered name of image size
  • @return string proper filename of image . */ function right_image_filename( $size ) {

return wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), $size)[0]; }

in data dialog select Advanced (php function return value)

insert 2 parameters: Function name right_image_filename Name of registered size image-489

and voila Works like a charm

This works wonderfully. Excellent work.

soterogouveia commented 2 years ago

vadimbk's answer worked perfecty!

Anyone found a workaround for using the same custom image sizes for the background images of sections and DIVs?

This would be equally useful!

Thank you

elmichalos commented 2 years ago

Oh yes much needed

DrZivil commented 2 years ago

+1

MimiDev commented 1 year ago

I just saw this thread here and I've been using this bit of code (that I add in Code Snippets) which adds the custom image sizes to the Oxygen Builder options. I can't actually remember where I found it, but maybe it's of help to others?

add_image_size( 'custom-image-one',500,325, true );
add_image_size( 'custom-image-two',1920,400, true );

/* use this to insert with PHP
    the_post_thumbnail( 'your-specified-image-size' );

    *** For use with the Oxy 'PHP function return value' data field ***
    get_the_post_thumbnail_url( ,'your-specified-image-size' );
    */

// Add our custom sizes to list of default image sizes
add_filter( 'image_size_names_choose', 'lit_merge_images_sizes' );
function lit_merge_images_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'custom-image-one' => __( 'Custom Image One' ),
        'custom-image-two' => __( 'Custom Image Two' ),
    ) );
}