This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This thread is resolved. Here is a description of the problem and solution.

Problem:
When uploading a custom flag, the site displays an error Call to undefined function mime_content_type() in ../wp-content/plugins/sitepress-multilingual-cms/inc/utilities/wpml-wp-api.class.php on line 13

Solution:
1. In your php.ini, enable the php_fileinfo extension (You may need to request your host company do this if you don't have access to your server).

2. If you can't access php.ini, you can go to sitepress-multilingual-cms/inc/utilities/wpml-wp-api.class.php and in the code:

public function get_file_mime_type( $filename ) {
 
        $mime_type = 'application/octet-stream';
        if ( file_exists( $filename ) ) {
            if ( function_exists( 'finfo_open' ) ) {
                $finfo     = finfo_open( FILEINFO_MIME_TYPE ); // return mime type ala mimetype extension
                $mime_type = finfo_file( $finfo, $filename );
                finfo_close( $finfo );
            } else {
                $mime_type = mime_content_type( $filename );
            }
        }
 
        return $mime_type;
    }

Change row 13:

$mime_type = mime_content_type( $filename );

to

$mime_type = 'image/gif';

This topic contains 5 replies, has 2 voices.

Last updated by Itamar 2 months, 3 weeks ago.

Assigned support staff: Itamar.

Author Posts
July 30, 2019 at 8:56 am #4305889

michielB-2

I added a new language (Flemish/Vlaams) to WPML. But uploading a custom flag results in a fatal error. The flag is not being uploaded and on other pages I only see the text "Vlaams" and a broken image icon. I used the official Belgium flag icon from the WPML /res/flags folder.

With debugging on I see the following error:

Notice: Trying to get property of non-object in D:\Websites\atagbenelux.com\atagbenelux\wp-content\plugins\sitepress-multilingual-cms\menu\edit-languages.php on line 400

Notice: Trying to get property of non-object in D:\Websites\atagbenelux.com\atagbenelux\wp-content\plugins\sitepress-multilingual-cms\menu\edit-languages.php on line 401

Fatal error: Uncaught Error: Call to undefined function mime_content_type() in D:\Websites\atagbenelux.com\atagbenelux\wp-content\plugins\sitepress-multilingual-cms\classes\wpml-wp\class-wpml-wp-api.php:13 Stack trace: #0 D:\Websites\atagbenelux.com\atagbenelux\wp-content\plugins\sitepress-multilingual-cms\menu\edit-languages.php(938): WPML_WP_API->get_file_mime_type('C:\\Windows\\Temp...') #1 D:\Websites\atagbenelux.com\atagbenelux\wp-content\plugins\sitepress-multilingual-cms\menu\edit-languages.php(559): SitePress_EditLanguages->upload_flag(65) #2 D:\Websites\atagbenelux.com\atagbenelux\wp-content\plugins\sitepress-multilingual-cms\menu\edit-languages.php(528): SitePress_EditLanguages->handle_flag_post_data(Array, 65) #3 D:\Websites\atagbenelux.com\atagbenelux\wp-content\plugins\sitepress-multilingual-cms\menu\edit-languages.php(91): SitePress_EditLanguages->update() #4 D:\Websites\atagbenelux.com\atagbenelux\wp-content\plugins\sitepress-multilingual-cms\menu\languages.php(25): SitePress_EditLanguages->__construct(Obje in D:\Websites\atagbenelux.com\atagbenelux\wp-content\plugins\sitepress-multilingual-cms\classes\wpml-wp\class-wpml-wp-api.php on line 13

July 30, 2019 at 10:27 am #4306905

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

This ticket has been inactive for quite a while, so I'm transforming this chat into a support ticket because I believe you're still encountering the problem.

I've found what might be the issue on your site. Please see the solution on this ticket here.
https://wpml.org/forums/topic/call-to-undefined-function-mime_content_type-wpml-wp-api-class-php-on-line-1/
See the solution in the top yellow section.
Please let me know if it is helpful to you.

Thanks,
Itamar.

July 30, 2019 at 12:44 pm #4307733

michielB-2

Changing the wpml-wp-api.class.php does remove the fatal error, but still no image is being processed after uploading. Nothing seems to happen.

July 30, 2019 at 1:25 pm #4307959

michielB-2

I resolved it. Like a lot of other topics about custom languages/flags I had to add an reference/item to this new language to the icl_flags database. With the right filename added to it, it now shows the correct flag.

Quite difficult and a lot of searching to have this fixed. This seems to be quite a common issue as so many users report flags not showing for custom images. Maybe a fix can be realized for a more permanent solution for all WPML users.

July 30, 2019 at 1:37 pm #4308093

michielB-2

My issue is resolved now. Thank you!

July 30, 2019 at 2:04 pm #4308275

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Great, I'm glad that it is solved now!

I think that the reference for the image of the flag in the icl_flags was missing in your case because of the fatal error. When I add a custom language to my test site and upload a flag, everything works correctly.

Good luck with your web projects 🙂
Itamar.