Announcement

Collapse
No announcement yet.

Facebook sharing of images

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Facebook sharing of images

    I've been using this code and I think it needs some updating because it sort of has a mind of it's own

    Code:
    <mvt:assign name="g.socialURL" value="l.settings:product:link" />
        <mvt:assign name="g.socialText" value="'Check out the deal on ' $ l.settings:product:name $ ' at ' $ g.store:name" />
        <mvt:do name="l.success" file="g.Module_Library_DB" value="ProductImage_Load_Type(l.settings:product:id, 1, l.settings:imagetype)" />
        <mvt:do name="l.success" file="g.Module_Library_DB" value="Image_Load_ID(l.settings:imagetype:image_id, l.settings:imagedata)" />
        <mvt:assign name="g.socialImage" value="g.baseurl $ l.settings:imagedata:image" />
        <meta property="og:title" content="&mvte:product:name;" />
        <meta property="og:type" content="product" />
        <meta property="og:image" content="&mvt:global:socialImage;" />
        <meta property="og:url" content="&mvt:global:socialURL;" />
        <meta property="og:site_name" content="&mvte:global:store:name;" />
        <meta property="og:description" content="&mvte:global:socialText;" />
    I know I have to make sure an Image Type is assigned - Main is what this store uses for the Additional Images but not every product is using the Additional Images. Some products are still using the Legacy Full-sized Images and not pulling in an image

    I've noticed that if there are Related Products on the page, the sharing will pull up an image from a Related Product instead of Product.

    http://www.serendipitystamps.com/new-stamps/094GD.html
    http://www.serendipitystamps.com/new-stamps/093ED.html

    So what would be the correct code or better way to do this?



    Leslie Kirk
    Miva Certified Developer
    Miva Merchant Specialist since 1997
    Previously of Webs Your Way
    (aka Leslie Nord leslienord)

    Email me: [email protected]
    www.lesliekirk.com

    Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

    #2
    I second that question... your post made me realize that I haven't checked my social sharing buttons in quite a while, and when I did I found that they no longer pull my product images at all.
    Psydde Delicious
    Delicious Boutique & Corseterie
    Philadelphia, PA
    www.DeliciousBoutique.com
    www.DeliciousCorsets.com

    Comment


      #3
      This code assumes that the first image type created for the site was the "main" image. If it is not, it will pull the first one which may not be the main image. You would need to check your main image type ID in the database to confirm which number should be pulled.
      Matt Zimmermann

      Miva Web Developer
      Alchemy Web Development
      https://www.alchemywebdev.com
      Site Development - Maintenance - Consultation

      Miva Certified Developer
      Miva Professional Developer

      https://www.dev4web.net | Twitter

      Comment


        #4
        Originally posted by Matt Zimmermann View Post
        This code assumes that the first image type created for the site was the "main" image. If it is not, it will pull the first one which may not be the main image. You would need to check your main image type ID in the database to confirm which number should be pulled.

        On all of this sites I've used this code on, it seems to just generate (I changed it to www.domain.com for example purposes):

        Code:
         
         <meta property="og:image" content="https://www.domain.com/mm5/" />
        Can the code be updated to use check for the Legacy Image?


        Leslie Kirk
        Miva Certified Developer
        Miva Merchant Specialist since 1997
        Previously of Webs Your Way
        (aka Leslie Nord leslienord)

        Email me: [email protected]
        www.lesliekirk.com

        Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

        Comment


          #5
          Hmmm, I just checked a site that IS using the "first image type created for the site was the "main" image" - it's still generating:

          Code:
           
           <meta property="og:image" content="https://www.domain.com/mm5/" />
          Now what?
          Leslie Kirk
          Miva Certified Developer
          Miva Merchant Specialist since 1997
          Previously of Webs Your Way
          (aka Leslie Nord leslienord)

          Email me: [email protected]
          www.lesliekirk.com

          Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

          Comment


            #6
            Question - I'd like to be able to create a custom image that is used just for this link. I thought I was on the right track with the coding but I'm still getting a "blank"

            Code:
            <mvt:assign name="g.socialURL" value="l.settings:product:link" />
                <mvt:assign name="g.socialText" value="'Check out the deal on ' $ l.settings:product:name $ ' at ' $ g.store:name" />
            <mvt:comment>    
            <mvt:do name="l.success" file="g.Module_Library_DB" value="ProductImage_Load_Type(l.settings:product:id, 1, l.settings:imagetype)" />
                <mvt:do name="l.success" file="g.Module_Library_DB" value="Image_Load_ID(l.settings:imagetype:image_id, l.settings:imagedata)" />
                <mvt:assign name="g.socialImage" value="g.baseurl $ l.settings:imagedata:image" />
            </mvt:comment>
                <meta property="og:title" content="&mvte:product:name;" />
                <meta property="og:type" content="product" />
                <mvt:if expr="l.settings:product:customfield_values:productimagecustomfields:cardfb">
              <meta property="og:image" content="http://www.domain.com/mm5/&mvt:product:customfield_values:productimagecustomfields:cardfb;" />
              <mvt:elseif expr="l.settings:product:customfield_values:productimagecustomfields:main">
              <meta property="og:image" content="http://www.domain.com/mm5/&mvt:product:customfield_values:productimagecustomfields:main;" />
              <mvt:else>
              <meta property="og:image" content="http://www.domain.com/mm5/&mvt:product:image;" />
            </mvt:if>
                <meta property="og:url" content="&mvt:global:socialURL;" />
                <meta property="og:site_name" content="&mvte:global:store:name;" />
                <meta property="og:description" content="&mvte:global:socialText;" />
            Leslie Kirk
            Miva Certified Developer
            Miva Merchant Specialist since 1997
            Previously of Webs Your Way
            (aka Leslie Nord leslienord)

            Email me: [email protected]
            www.lesliekirk.com

            Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

            Comment


              #7
              Here is some sample code which lets you define which image type you want to use:



              Code:
              <mvt:do file="g.Module_Library_DB" name="l.success" value="ImageType_Load_Code('main', l.settings:imagetype)" />
              <mvt:do name="l.success" file="g.Module_Library_DB" value="ProductImage_Load_Type(l.settings:product:id, l.settings:imagetype:id, l.settings:imagetypedata)" />
              <mvt:do name="l.success" file="g.Module_Library_DB" value="Image_Load_ID(l.settings:imagetypedata:image_id , l.settings:imagedata)" />
              
              &mvt:imagedata:image;



              Brennan Heyde
              VP Product
              Miva, Inc.
              [email protected]
              https://www.miva.com

              Comment


                #8
                Originally posted by Brennan View Post
                Here is some sample code which lets you define which image type you want to use:



                Code:
                <mvt:do file="g.Module_Library_DB" name="l.success" value="ImageType_Load_Code('main', l.settings:imagetype)" />
                <mvt:do name="l.success" file="g.Module_Library_DB" value="ProductImage_Load_Type(l.settings:product:id, l.settings:imagetype:id, l.settings:imagetypedata)" />
                <mvt:do name="l.success" file="g.Module_Library_DB" value="Image_Load_ID(l.settings:imagetypedata:image_id , l.settings:imagedata)" />
                
                &mvt:imagedata:image;


                Okay and what if the store hasn't defined all of it's images with an Image Type? This particular store has two Image Types plus a large number of images are still Legacy. In the case of this store that I originally posted for, they want to use the Image Type "cardfb" so if I under stand correctly I would use:

                Code:
                 
                 <mvt:do file="g.Module_Library_DB" name="l.success" value="ImageType_Load_Code('cardfb', l.settings:imagetype)" /> <mvt:do name="l.success" file="g.Module_Library_DB" value="ProductImage_Load_Type(l.settings:product:id, l.settings:imagetype:id, l.settings:imagetypedata)" /> <mvt:do name="l.success" file="g.Module_Library_DB" value="Image_Load_ID(l.settings:imagetypedata:image_id , l.settings:imagedata)" />  &mvt:imagedata:image;
                What happens if the product only has the "main" Image Type assigned or the product is still using the Legacy images?

                Leslie Kirk
                Miva Certified Developer
                Miva Merchant Specialist since 1997
                Previously of Webs Your Way
                (aka Leslie Nord leslienord)

                Email me: [email protected]
                www.lesliekirk.com

                Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                Comment


                  #9
                  <mvt:item name="toolkit" param="customimagec|big|g.product_code||360|360|1" />
                  <meta property="og:image" content="https://www.yourdomain.com/mm5/&mvte:global:big;"/>
                  <meta property="og:image:width" content="360" />
                  <meta property="og:image:height" content="360" />
                  Last edited by Mark Hood; 03-05-18, 09:48 AM.
                  Mark Hood
                  Vermont Gear

                  Comment


                    #10
                    Originally posted by Mark Hood View Post
                    <mvt:item name="toolkit" param="customimagec|big|g.product_code||360|360|1" />
                    <meta property="og:image" content="https://www.yourdomain.com/mm5/&mvte:global:big;"/>
                    Hi Mark - I'm trying to convert to something without the Toolkit. Using Bill's Toolkit is my number 1 go to (and I use this snippet a LOT) but sadly, we know that at some point in time we have to move on...
                    Leslie Kirk
                    Miva Certified Developer
                    Miva Merchant Specialist since 1997
                    Previously of Webs Your Way
                    (aka Leslie Nord leslienord)

                    Email me: [email protected]
                    www.lesliekirk.com

                    Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                    Comment


                      #11
                      Originally posted by lesliekirk View Post

                      Hi Mark - I'm trying to convert to something without the Toolkit. Using Bill's Toolkit is my number 1 go to (and I use this snippet a LOT) but sadly, we know that at some point in time we have to move on...
                      Sadly I agree but his code sure did work once you got it figured out :)
                      Mark Hood
                      Vermont Gear

                      Comment


                        #12
                        Leslie, I have the same issue with the image link in that part of the code AND also with the url ... does your url for product screen populate currently? I am using Levels ready theme... Are you?

                        I also am getting a null value for
                        l.settings:product:link and so g.socialURL is empty are you?
                        Last edited by kayakbabe; 03-22-18, 06:24 PM.

                        Comment


                          #13
                          Originally posted by kayakbabe View Post
                          Leslie, I have the same issue with the image link in that part of the code AND also with the url ... does your url for product screen populate currently? I am using Levels ready theme... Are you?

                          I also am getting a null value for
                          l.settings:product:link and so g.socialURL is empty are you?
                          I was able to get the thing working on a Levels site using this:

                          <meta property="og:image" content="https://www.domain.com/mm5/&mvt:product:customfield_values:productimagecustom fields:main;" />
                          Leslie Kirk
                          Miva Certified Developer
                          Miva Merchant Specialist since 1997
                          Previously of Webs Your Way
                          (aka Leslie Nord leslienord)

                          Email me: [email protected]
                          www.lesliekirk.com

                          Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                          Comment

                          Working...
                          X