url 活动存储 rails_blob_path 有效用于元标记

is url active storage with rails_blob_path valid to use in meta tags

我有一个模型用户,其中有一个 avatar,我为 og:imagerails_blob_path 设置了 元标记 ,我将其设置在控制器及其 URL 的结果喜欢:

myappname/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZpud9--aa382324e6d9968973/thepic-here-3783384.jpg?disposition=attachment

如果处于development模式,如果处于production模式,那么URL设置到meta标签是否有效] og:image ?

在那种情况下,您需要完整的 URL。特别是,我使用方便的 url_for 方法,如下所示:

url_for(asset.variant(
                resize_to_limit: [max_width, max_height]
              ))

此外,我发现某些应用程序要正确解析您的图像(例如 Whatsapp),最好排除方案(https http), 从而得到一个像这样的元标签:

<meta property="og:image" itemprop="image" content="//yourcoolsite.com/rails/active_storage/representations/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbDhFIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--0507940c0531918f2c8a85ec0eba799b5a291789/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9VY21WemFYcGxYM1J2WDJ4cGJXbDBXd2/logo.jpg">

希望对您有所帮助!