ThemeFuse / Unyson

A WordPress framework that facilitates the development of WP themes
http://unyson.io
925 stars 220 forks source link

How do we get all available image sizes in theme settings? #3286

Closed danyj closed 6 years ago

danyj commented 6 years ago

I asked this before https://github.com/ThemeFuse/Unyson/issues/2419

but was not able to get a solution and now the issue is pressing.

I need to get all available image sizes inside the theme options and if you do

fw_print(get_intermediate_image_sizes()); on top of settings.php

we only get the default WP sizes ,

array
(
    [0] => 'thumbnail'
    [1] => 'medium'
    [2] => 'medium_large'
    [3] => 'large'
)

our sizes added on after_setup_theme, WooCommerce image size or any plugin image sizes are not available and they should be.

Looks like the framework bootstrap runs before everything.

danyj commented 6 years ago

even this https://github.com/ThemeFuse/Unyson/blob/be11ea3e8a351f340ec18d0600eb4a7dc0e87f79/framework/helpers/general.php#L1753

fw_get_image_sizes();

does not see them all,

ViorelEremia commented 6 years ago

I tried with the scratch theme and the core it seems to work

danyj commented 6 years ago

what did you try please?

you add own image size on after_setup_theme and you see it printend in admin ?

how abut woocomerce ?

ViorelEremia commented 6 years ago

with scratch theme

array
(
    [0] => 'thumbnail'
    [1] => 'medium'
    [2] => 'medium_large'
    [3] => 'large'
    [4] => 'post-thumbnail'
    [5] => 'fw-theme-full-width'
    [6] => 'test-image'
    [7] => 'woocommerce_thumbnail'
    [8] => 'woocommerce_single'
    [9] => 'woocommerce_gallery_thumbnail'
    [10] => 'shop_catalog'
    [11] => 'shop_single'
    [12] => 'shop_thumbnail'
)

with the core

array
(
    [0] => 'thumbnail'
    [1] => 'medium'
    [2] => 'medium_large'
    [3] => 'large'
    [4] => 'fw-theme-full-hd'
    [5] => 'fw-theme-blog-full'
    [6] => 'fw-theme-blog-sidebar'
    [7] => 'fw-theme-portfolio-landscape'
    [8] => 'fw-theme-portfolio-landscape-x2'
    [9] => 'fw-theme-category-slider'
    [10] => 'fw-theme-category-slider-2x'
    [11] => 'fw-theme-gallery-2-1'
    [12] => 'fw-theme-gallery-2-1-x2'
    [13] => 'fw-theme-gallery-1-2'
    [14] => 'fw-theme-gallery-1-2-x2'
    [15] => 'fw-theme-portfolio-portrait'
    [16] => 'fw-theme-portfolio-portrait-x2'
    [17] => 'fw-theme-three-quarters'
    [18] => 'fw-theme-three-quarters-x2'
    [19] => 'fw-theme-gallery-five-three'
    [20] => 'fw-theme-gallery-five-three-x2'
    [21] => 'fw-theme-gallery-three-two'
    [22] => 'fw-theme-gallery-three-two-x2'
    [23] => 'fw-theme-category-square-800'
    [24] => 'fw-theme-category-square-300'
    [25] => 'woocommerce_thumbnail'
    [26] => 'woocommerce_single'
    [27] => 'woocommerce_gallery_thumbnail'
    [28] => 'shop_catalog'
    [29] => 'shop_single'
    [30] => 'shop_thumbnail'
)

I added fw_print(get_intermediate_image_sizes()); to \the-core\the-core-parent\framework-customizations\theme\options\settings.php

danyj commented 6 years ago

strange I am only getting the defaults, digging, thnx

danyj commented 6 years ago

found it, was loading fw_get_db_settings_option on widgets_init and after_setup_theme priority 9 so it was loading the setup.php before init thank you!