【问题标题】:TYPO3 - Output the image path via typoscript and database?TYPO3 - 通过打字稿和数据库输出图像路径?
【发布时间】:2017-11-08 16:30:39
【问题描述】:

在我的数据库中是 TYPO3 媒体图像文件: header_image = 1

表:tx_test

字段:header_image

如何输出图片链接? 我想我需要 IMG_RESOURCE 和 RECORDS 吗?

但我现在不工作了。我的测试:

10 = FILES
10 {
    references {
        table = tx_test
        #uid.data = uid
        fieldName = header_image
    }
    renderObj = RECORDS
    renderObj {
        10 = IMG_RESOURCE
        10 {
            file {
                treatIdAsReference = 1
                import.data = file:current:publicUrl
            }
        }
    }
}

完美运行!

#Title
    testTitle = COA
    testTitle {

        # Titel
        10 = RECORDS
        10 {
            source = 1
            dontCheckPid = 1
            tables = tx_test
            conf {
                tx_test = TEXT
                tx_test {
                    field = title
                    crop = 80 | | 1
                    stripHtml = 1
                    htmlSpecialChars = 1
                }
            }
        }
        stdWrap.noTrimWrap = |<title>|</title>|
        stdWrap.insertData = 1
    }

谢谢!

【问题讨论】:

  • 你的目标 HTML 输出是什么?
  • 我使用其他代码作为标题和说明,这很好。但现在我需要 og:image 元标记:

标签: database typo3 typoscript typo3-8.7.x


【解决方案1】:

如果您真的只想要图像的 URI,这应该可以完成工作。

10 = FILES
10 {
    references {
        table = tx_test
        # YOU NEED AN UID HERE!
        #uid.data = uid
        fieldName = header_image
    }
    renderObj = TEXT
    renderObj {
        data = file:current:publicUrl
    }
}

【讨论】:

  • 您使用的是哪个 TYPO3 版本?您如何提供记录的 UID(向我们展示 Typoscript),请向我们提供字段 header_image 的 TCA 配置。
  • TYPO3 8.7 我在 TYPo3 BE SysFolder 中有所有“项目”,但这不是 UID,这是 PID 还是?
  • 您必须在“header_image”字段中提供具有图像的记录的 UID - 而不是保存记录的页面。
  • mh,这一直是另一个 UID :) 与我现在使用的 tx_news / news-articel 相同:uid.data = uid - 但它不起作用跨度>
  • 好的,动态制作没问题。您想在哪种情况下显示 URI?如果它是您记录的一种“详细信息页面”,请从 GET 变量中获取 UID。
【解决方案2】:

解决方案在这里:

感谢保罗·贝克

使用图像裁剪的图像输出:

10 = FILES
        10 {
            references {
                table = tx_ext_name
                uid.data = GP:tx_ext_action|tx_ext_controller
                fieldName = header_image
            }
            renderObj = IMG_RESOURCE
            renderObj {
                file {
                    treatIdAsReference = 1
                    import.data = file:current:uid
                    width = 1200c
                    height = 630c
                }
            }
        }

或者对于普通的图片-url:

10 = FILES
        10 {
            references {
                table = tx_ext_name
                uid.data = GP:tx_ext_action|tx_ext_controller
                fieldName = header_image
            }
                renderObj = TEXT
                renderObj {
                    data = file:current:publicUrl
                }
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-15
    • 1970-01-01
    • 2021-11-29
    • 2018-12-19
    相关资源
    最近更新 更多