Okay
  Public Ticket #856311
Pictures not Loading in Safari
Closed

Comments

  • Halley started the conversation

    So I just did an upload of products and images using a CSV file, very similar to what I have done in the past.. there is a bit of a problem, however.

    The product images look fine on Chrome

    The majority of the images won’t load on Safari.

    However, if you click on the question mark where the picture should be (on the product page) in Safari, the picture pops up and looks fine..

    Thoughts?

  • Halley replied

    Update:


    If I add the photo again directly through wordpress media (and not the server), the pictures seems to show (in safari) up when I change the product image to the new one uploaded through wordpress.

    If I delete the new upload and go back to the original picture (uploaded through the server), I get the blue question mark again.


    This is the first time I have had this problem, and I have uploaded most of the images through the server... This might be a wordpress issue but I thought I would start by asking you guys

  • Halley replied

    Further Update:

    If there are multiple pictures (i.e.: a product with variables), and you select the color and size that you want from the drop down menu, the picture shows up.

    The same file name is used for both the variable picture and the product image picture... but one shows up and one does not

    http://shopottawagoodtime.com/product/forma-boulder/

  • [deleted] replied

    Hi Halley

    The reason why images are not shown in Safari is because your file names contains space characters, so I have applied the following fix:

    // Media Names Fix
    function fix_image_name_renamer( $url ) {
    $name = basename( $url );
    return str_replace( $name, str_replace( ' ', '-', $name ), $url );
    }

    function fix_wp_calculate_image_srcset( $sources ) {

    foreach ( $sources as $i => & $source ) {
    $source['url'] = fix_image_name_renamer( $source['url'] );
    }

    return $sources;
    }

    function fix_wp_get_attachment_image_attributes( $attrs ) {

    foreach( array( 'src', 'url' ) as $attr_id ) {

    if ( isset( $attrs[ $attr_id ] ) ) {
    $attrs[ $attr_id ] = fix_image_name_renamer( $attrs[ $attr_id ] );
    }
    }


    return $attrs;
    }

    add_filter( 'wp_calculate_image_srcset', 'fix_wp_calculate_image_srcset' );
    add_filter( 'wp_get_attachment_image_attributes', 'fix_wp_get_attachment_image_attributes' );

    In functions.php and it fixed the issue.

  • Halley replied

    Thank you so much for trying... unfortunately, this was the view from y screen this morning...



    If you search for the brand FORMA boots, this seems to have the most issues.

  • [deleted] replied

    Hi Halley,

    I've run a batch name replace (copying files with spaces and renaming them by replacing space with dash) for exampe:

    /wp-content/uploads/2016/08/buckle BLACK.jpg

    The script copied the file with different name:

    /wp-content/uploads/2016/08/buckle-BLACK.jpg

    The first file (with space character) still remains there.

    So this fixed the issue. 

    I've also installed this plugin yesterday:


    (view large version)

    So keep it, it will rename images with invalid or space characters when they are uploaded.

  • Halley replied

    Thank you Arlind!  I really appreciate the fantastic support.

  • Halley replied

    Does the plug-in run automatically or do I run it?

    Also, does it work for files uploaded through our server or should I upload the files through the media backend in wordpress?

  • [deleted] replied

    Hi Halley,

    The "batch" process I've run was initiated only once, and you don't need to run it again.

    However, you need to upload files via Media section of WordPress, thats better way and will create thumbnails, rename/clean file names that are not recognized in several browsers.

  • Halley replied

    Thanks again for you help on this topic.

  • [deleted] replied

    Hi Halley,

    Glad to hear that :)

    If you like our theme, it would help us a lot if you could give us five star rating on themeforest from your Downloads tab, (if you don't know how, just open this link).

    A huge thank you from Laborator in advance and have a great day!