External image file as hover/swap image - by Royalty

This topic has 11 replies, 2 voices, and was last updated 6 years, 9 months ago ago by Rose Tyler

  • Avatar: Royalty
    Royalty
    Participant
    July 18, 2017 at 11:21

    Hello,
    I created a custom cdn to deliver my images. All uploads are no longer located in the default wp-content/uploads folder but in media.mydomain.com. I updated the database and everything works fine – except the swap images on product archive page. Please find more details in private content as I dont want my domain or screenshots of my page to be public. Thank you.

    Please, contact administrator
    for this information.
    10 Answers
    Avatar: Royalty
    Royalty
    Participant
    July 18, 2017 at 15:00

    I fixed it by changing the following code in content-product.php line 83:

    From:
    <img src="<?php echo $hoverImg['url']; ?>"...
    To:
    <img src="<?php echo apply_filters( 'the_content', get_post_meta( $post->ID, 'hover_img', true ) );?>"...

    But thats weird. It should be possible without any customizations…

    Avatar: Royalty
    Royalty
    Participant
    July 18, 2017 at 15:02

    Just noticed that my customizations are not good as it grabs the full size image instead of the shop catalog size…So any help how to fix this is a clean way would be perfect. Thank you.

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    July 19, 2017 at 12:33

    Hello,

    Unfortunately, it requests a lot of additional customization. You may contact WPKraken team to get help with additional customization.

    Regards

    Avatar: Royalty
    Royalty
    Participant
    July 19, 2017 at 13:30

    I wanted to solve this by adding link to the scaled image (media.mydomain.com/myimage-420×420.jpg) as hover image, but when I do this, the “x” in 420X420 is transformed in an “×” and that causes that the url doesnt work. This is a really weird behavior. Do you have any idea how to fix this x-issue?
    Many thanks!

    Avatar: Royalty
    Royalty
    Participant
    July 19, 2017 at 13:32

    This is so weird, it does the same here in this forum. I am typing an small “x” and after sending my message it shows this: ×

    Avatar: Royalty
    Royalty
    Participant
    July 19, 2017 at 15:04

    I solved this by adding only “media.mydomain.com/myimage” (without .jpg) as hover image and then adding this code to content-product.php:
    <img src="<?php echo apply_filters( 'the_content', get_post_meta( $post->ID, 'hover_img', true ) )."-420x420.jpg";?>"
    I know that this is really bad coding, so if you have any idea why the “x” is tranformed, I would prefer to fix this and use the link to the scaled image instead. Thank you..

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    July 19, 2017 at 15:14

    I am not sure, but try to add \ before “x”

    Regards

    Avatar: Royalty
    Royalty
    Participant
    July 19, 2017 at 15:24

    Thank you, but unfortunately the x is still transformed. Tried it with a big X but that did not help either (the big X is not transformed but it has to be a small x to work)…so weird, I really dont understand what happend here and would like to know if its theme related or not…will do some more tests but maybe you know another solution?

    Avatar: Royalty
    Royalty
    Participant
    July 19, 2017 at 15:36

    Got it. Somehow my custom code to output the custom field was causing the x-transformation. Outputted it now as shortcode and that did the trick…

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    July 19, 2017 at 15:41

    I’m glad that you sorted out.

    Regards

  • Viewing 11 results - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.