PHPanos
Forum Replies Created
-
And if this “fix” would be implemented, you probably want to adjust the check for empty post_title in the generate_explenation function to avoid the message “This title cannot be used for a filename” when a title has been generated through the filter instead of the post_title field. And probably just have a general title variable regardless of where the title comes from, whether it’s from the post_title field or a filter.
Hope this makes sense.
Hi Jordy,
Basically I just moved the lines 989 and 990 in media-file-renamer.php:
$sanitized_media_title = $this->new_filename( $post, $base_new_title, $forceFilename ); $this->log( "New file should be: " . $sanitized_media_title );
to right above this code on line 971-972:
// Empty post title when renaming using title? Let's not go further. if ( !$force && empty( $base_new_title ) ) {
and also edited the if statement above to:
if ( !$force && empty( $base_new_title ) && empty( $sanitized_media_title ) ) {
This was really just to fit my needs and could probably need a bit of testing, but the main issue is just the check on line 972 (when using the “mfrh_new_filename” filter) ??
In my case I think it has to do with the encoding of the filename and the locale+encoding on the operating system. My image files could contain the swedish letters ??? which causes a problem if the system doesn’t have that locale.
I got the error message “The field couldn’t be renamed from old/filepath/ to new/filepath” so I dug into the plugin just to learn more about that message. In the file media-file-renamer.php on line 1043 there’s this check:
if ( ( !file_exists( $old_filepath ) || !rename( $old_filepath, $new_filepath ) ) && !$force_rename ) {
I printed out old_filepath and instead of the ??? letters i saw utf-8 literals like this: “path/imagexc3\xb6.jpg” when it should be “path/image?.jpg”.
This was on a debian machine. I then tried it on my mac and it worked and the output of the filename was correct.
Bottom line is I think the problem has to do with the encoding. Encoding for me has always been a headache ??
Ok my bad. I managed to get the files on the server to change when trying on my other computer. The difference was that I had the correct locale installed on my other computer (which matched the file names). Thanks for a wonderful plugin Jordy Meow!
Any updates on this one? I also have problems where the plugins change the filename in the database, but not on the actual physical file.
@extremecarver: I know that IFs are evil and rewrite should be avoided. I already have that on my location / block and that was the first thing I tried, but it would only give me 404 on all pages. Can I mail you or something? I would like to fix this the proper way and my config is really simple. Thanks!
EDIT: It works! There was a missing semi colon within this code:
index index.php index.html index.htm;EDIT 2: I added ?$args else the search wouldn’t work.
try_files $uri $uri/ /index.php?$args;
Thank you!
Forum: Plugins
In reply to: [qTranslate X] No way to switch languageI also have this problem. @gianluca Del Gobbo solution works for me.
Hi @gunu & @john Clause. John you were right, it seems to have to do with my nginx conf.
I changed from the following in my vhost conf:
if (!-e $request_filename) { rewrite ^(.+)$ /index.php?q=$1 last; }
To this:
if (!-e $request_filename) { rewrite ^(.+)$ /index.php last; }
Basically I just removed the ?q=$1 parameter.
Thanks for taking your time helping me out!
@john Clause: Yes I do. Version 3.3. Also tried it on the development version and I have the same issue over there. I am using nginx for my site, I’ll try apache and see if it works better.
If I hardcode my default language in this function the language switching works:
function qtranxf_set_language_cookie($lang) { global $q_config; if(defined('WP_ADMIN')){ //qtranxf_dbg_log('qtranxf_set_language_cookie: QTX_COOKIE_NAME_ADMIN: lang=',$lang); qtranxf_setcookie_language( $lang, QTX_COOKIE_NAME_ADMIN, ADMIN_COOKIE_PATH ); }elseif(!$q_config['disable_client_cookies']){ $lang = 'en'; qtranxf_setcookie_language( $lang, QTX_COOKIE_NAME_FRONT, COOKIEPATH, NULL, $q_config['use_secure_cookie'] ); } }
Notice: Undefined variable: where in /usr/share/nginx/html/openaid.se/wp-content/plugins/qtranslate-x/qtranslate_frontend.php on line 238
I get this whenever I refresh the page. Does it help?
@gunu: Permalinks are set to postname. I’m using nginx.
@gunu: No. I tried to reset the settings on 3.2.9 as well. It always redirects me to non-default language. So strange!
Unchecking “Hide URL language information for default language.” makes it works to switch language, but I don’t want url for default language.
@gunu: I tried it. It didn’t work. I really appreciate all the help.
It will not switch to non-default language either. Are there new rewrite rules in qTranslate X?
@gunu: I just had Magic Fields activated and disabled it. Nothing changed. I also tried with Twenty Fifteen theme and it wouldn’t change language from the url.