Icon field not loading icons in post edit page

Support MB Builder Icon field not loading icons in post edit page

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #44016
    Elene GabelaiaElene Gabelaia
    Participant

    Hello,

    I have an issue with the icon field, using custom SVG icons.

    I tried both methods described here: https://docs.metabox.io/fields/icon/#using-svgs
    1. Adding the dir to the svg files directory (tried relative/absolute path)
    2. Adding the svg code directly in a json file

    In both cases the icons wont load in the post edit screen
    (link to screenshot: https://drive.google.com/file/d/1m0Mk_aDdL3SehnHYbAyXJnZgy2tDCDwa/view?usp=sharing)

    If I use the free Awesome Fonts the field works fine.

    Can you help?

    Kind regards

    #44024
    PeterPeter
    Moderator

    Hello Elene,

    What is the absolute path you add to the icon dir setting? Simply, you can echo the WordPress function get_stylesheet_directory() to get the path to the current theme folder.

    #44034
    Elene GabelaiaElene Gabelaia
    Participant

    I tried all the following paths without success:
    - https://example.com/wp-content/themes/mytheme/assets/svg/
    - /wp-content/themes/mytheme/assets/svg/
    - wp-content/themes/mytheme/assets/svg/

    get_stylesheet_directory() retrieves the absolute path on the server, so I tried also the following paths, without success:
    - /home/user/public_html/wp-content/themes/mytheme/assets/svg/
    - home/user/public_html/wp-content/themes/mytheme/assets/svg/

    Kind regards

    #44042
    PeterPeter
    Moderator

    Hello,

    Please share your site credentials via this contact form https://metabox.io/contact/
    I will take a look.

    #44043
    Elene GabelaiaElene Gabelaia
    Participant

    I sent them to you, thanks.

    #44044
    Elene GabelaiaElene Gabelaia
    Participant

    The new icon field is added here with name "New Icon field": https://pbservices.ge/wp-admin/post.php?post=16182&action=edit
    And it is visible in this post type under the tab "Features Bottom": https://pbservices.ge/wp-admin/post.php?post=19547&action=edit

    #44045
    PeterPeter
    Moderator

    Hello,

    The correct path is

    /home2/pbfinanc/public_html/wp-content/themes/generatepress_child/assets/svg/
    

    I add it to the option icon_dir and the icons show as well, screenshot https://imgur.com/9i1OyaD

    #44046
    Elene GabelaiaElene Gabelaia
    Participant

    Thank you!

    I suggest you to update the docs/screenshot in the section https://docs.metabox.io/fields/icon/#using-svgs, as it may be misleading for other users.

    Kind regards

    #44048
    Elene GabelaiaElene Gabelaia
    Participant

    Sorry,

    I have a second issue when I try to output the SVG icon.

    With both these functions nothing is returned:

    {{ mb.rwmb_meta( clone.feature_icon_2 ) }}
    {{ mb.rwmb_the_value( clone.feature_icon_2 ) }}

    If I output instead directly the icon value, it shows correctly the icon name:
    {{ clone.feature_icon_2 }}
    outputs:
    bx-check-circle

    Am I using the wrong syntax to show the custom SVG code?

    Kind regards

    #44051
    PeterPeter
    Moderator

    Hello,

    The data saved to the database is the icon name so you should wrap it in an HTML tag to output the file URL. For example:

    {% for clone in post.group_field_id %}
    	{% set icon_name = clone.icon_field_id %}
    	<img src="{{ mb.get_stylesheet_directory_uri() }}/assets/svg/{{ icon_name }}.svg" />
    {% endfor %}
    #44172
    Elene GabelaiaElene Gabelaia
    Participant

    Hello,

    your solution was working good.
    But with the latest plugin update (Metabox version 5.9.1) the icon edit field does not load the icons again.

    The path that was currently working before the update was "/home*/***/***/wp-content/uploads/assets/svg/".

    Can you help?

    #44177
    LogLog
    Participant

    I can confirm that the icon field is no longer loading the assets as of 5.9.1 in both the builder and the front-end. In my case it is the default Font Awesome library. It is easy to duplicate the issue: simply add the icon field to your field group. Then in your custom post: attempt to select an icon but none appear.

    I assume it is from the update to 5.9.1, but I am unable to verify as the plugin immediately updates upon restoring a backup.

    #44183
    PeterPeter
    Moderator

    Hello,

    Please use the version 5.9.0 to show the icon field. The development team is checking the issue and I will let you know when I have any information.

    #44188
    LogLog
    Participant

    Hi Peter. I was able to revert and can confirm 5.9.0 works as expected.

    Previous versions can be downloaded at the WordPress Meta Box Plugin page → Advanced View → Previous Versions.

    Or use wp-cli like I did:

    cd wp-content/plugins
    wp plugin auto-updates disable meta*
    wp plugin delete meta-box && wp plugin install meta-box --version=5.9.0 --activate
    #44189
    Filippo PonzettiFilippo Ponzetti
    Participant

    Hi,

    I'm experiencing the same issue. How can I download the 5.9.0 version please? ]

    Thanks,
    Filippo

Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.