正确渲染wordpress中的图像

时间:2018-03-30 09:17:48

标签: wordpress image ionic-framework mobile ionic2

我有一个离子应用程序,我在其中显示我的wordpress帖子。但是wordpress帖子的图像没有正确显示/呈现。我正在使用wordpress API从wordpress网站上获取我的帖子。

示例 - enter image description here

用于呈现提取的wordpress后的模板代码片段

    <div *ngIf="selectedItem" class="selection">
       <h2 [innerHTML]="selectedItem.title.rendered"></h2>
       <p [innerHTML]="selectedItem.content.rendered" text-justify></p>
    </div>

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,非常简单明了 -

为该特定页面添加以下scss代码 -

class ViewController: NSViewController {

var text: NSTextField!

override func viewDidLoad() {
    super.viewDidLoad()

    text = NSTextField(frame: NSRect(origin: CGPoint(x: 200, y: 200), size: CGSize(width: 32, height: 32)))
    text.backgroundColor = .clear
    text.isBordered = true
    text.isEditable = false

    let attachment = NSTextAttachment()
    attachment.image = NSImage(named: NSImage.Name(rawValue: "Group_8"))
    attachment.bounds = NSRect(origin: .zero, size: (attachment.image?.size)!)

    let string = NSAttributedString(attachment: attachment)

    text.attributedStringValue = string

    view.addSubview(text)


    // Do any additional setup after loading the view.
}