We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    Hi there,
    I am creating Twitter and Facebook cards using an image TV for each of my resources
    If I just use the TV on its own, it doesn't work, because twitter requires an absolute URL.
    So I added the site_url property before the tv like so:
    <meta itemprop="image" content="[[++site_url]][[*SocialImage:pthumb=`&w=500&h=500` ]]" />
    
    

    But the output in the source code is rendered with a double forward slash like so:
    <meta itemprop="image" content="https://www.domain.com//path-to-social_image.png" />
    


    Although in a browser, this still seems to work, Facebook and Twitter don't seem to like it.
    Any ideas how to remove the extra slash?


    Thanks in advance

    Andy
      • 3749
      • 24,544 Posts
      Either SocialImage or pthumb is adding a leading slash.

      I think this would fix it, though it's kind of hacky:

      <meta itemprop="image" content="[[++site_url:removeTrailingSlash]][[*SocialImage:pthumb=`&w=500&h=500` ]]" />


      /* removeTrailingSlash snippet */
      return rtrim($input, '/');

        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 51020
        • 670 Posts
        Quote from: BobRay at Aug 30, 2018, 11:31 AM
        Either SocialImage or pthumb is adding a leading slash.

        I think this would fix it, though it's kind of hacky:

        <meta itemprop="image" content="[[++site_url:removeTrailingSlash]][[*SocialImage:pthumb=`&w=500&h=500` ]]">


        /* removeTrailingSlash snippet */
        return rtrim($input, '/');


        Thanks Bob - I just removed pThumb from the code, and it resolved the issue - so it is pThumb which is adding the additional slash. I will do some more digging to see if anyone else has experience the same issue with pThumb.

        Thanks for the steer!
        Andy
          • 36582
          • 463 Posts
          Andy, did you ever get to the bottom of this? I'm seeing the same thing.
            Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk
            • 51020
            • 670 Posts
            Quote from: chrisandy at Oct 30, 2018, 03:29 PM
            Andy, did you ever get to the bottom of this? I'm seeing the same thing.

            As per the thread, I had to remove pThumb from the image URL, and then it worked - not ideal, but it was sufficient for my needs - it just meant I had to manually resize the image.

            Hope this helps!
            Andy
              • 51020
              • 670 Posts
              Quote from: chrisandy at Oct 30, 2018, 03:29 PM
              Andy, did you ever get to the bottom of this? I'm seeing the same thing.

              As per the thread, I had to remove pThumb from the image URL, and then it worked - not ideal, but it was sufficient for my needs - it just meant I had to manually resize the image.

              Hope this helps!
              Andy
                • 36582
                • 463 Posts
                Ah ok - not an option for me but thanks for coming back to me.
                  Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk
                  • 3749
                  • 24,544 Posts
                  My solution above might solve it for you.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 36582
                    • 463 Posts
                    Thank you Bob - how would I use it if just calling?..

                    <img src="[[+myImage:pthumb=`w=200&h=200`]]" >
                      Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk
                      • 3749
                      • 24,544 Posts
                      Sorry, I missed your post. In case you haven't found it yet:

                      <img src="[[+myImage:pthumb=`w=200&h=200`:removeTrailingSlash]]" >
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting