【问题标题】:Unable to crop header image in my custom theme for wordpress无法在我的 wordpress 自定义主题中裁剪标题图像
【发布时间】:2016-01-31 09:38:27
【问题描述】:

从今天开始,我开始学习 wordpress 的自定义主题开发,但我目前遇到的问题是,当我尝试裁剪标题的图像时显示错误。下面是示例代码。

(1.我已经为函数.php设置了标题图像的钩子

add_theme_support('custom-header');

(2.在header.php里面设置图片

   <img class="myhead" src="<?php header_image(); ?>" height="<?php get_custom_header()->height ?>"
             width="<?php get_custom_header()->width ?>" alt="">

(3.测试图片是否会显示在header里面,图片是按实际大小显示的。

如何在 Customize 中自定义标题图片?我很想听听你的意见。

【问题讨论】:

  • 你用的是哪个主题?

标签: php css wordpress image


【解决方案1】:

flex-width & flex-height是自行调整,

 $args = array(
        'flex-width'    => true,
        'width'         => 980,
        'flex-height'    => true,
        'height'        => 200,
        'default-image' => get_template_directory_uri() . '/images/header.jpg',
    );
    add_theme_support( 'custom-header', $args );

更新你的 header.php

<img alt="" src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" />

【讨论】:

    猜你喜欢
    • 2014-04-05
    • 1970-01-01
    • 1970-01-01
    • 2016-04-02
    • 2017-05-22
    • 1970-01-01
    • 1970-01-01
    • 2014-08-01
    • 1970-01-01
    相关资源
    最近更新 更多