如何在WordPress内使用php将用户输入附加到图像?

时间:2018-11-12 13:57:40

标签: php wordpress

我们最近进行了一个正在进行的项目,该项目提供网络维护。

我们必须向用户提供调查问卷,在调查结束时,他们(即用户)将获得文凭。如果需要,我们需要一种将在输入标签中输入的用户名附加到图像(文凭模板)的方法。

忘记了WordPress部分,它与PHP手册一起看起来非常流畅。但是,为了做到这一点,我们需要找到一种在帖子内显示该图像的方法。

以下几行负责处理图像,附加字符串并构建用于图像驻留的帖子。

Control CurrentContextMenuOwner = null;

private void contextMenuStrip1_Opened(object sender, EventArgs e)
{
    CurrentContextMenuOwner = (sender as ContextMenuStrip).SourceControl;
}

private void toolStripMenuItem_Click(object sender, EventArgs e)
{
    CurrentContextMenuOwner.BackColor = Color.Blue;
    //(...)
}

private void contextMenuStrip1_Closed(object sender, ToolStripDropDownClosedEventArgs e)
{
    CurrentContextMenuOwner = null;
}

图片触发来自jQuery

add_action( 'init', 'custom_post_type', 0 ); 
add_action( 'wp_ajax_diploma_new_image', 'diploma_new_image' );
add_action( 'wp_ajax_nopriv_diploma_new_image', 'diploma_new_image' );

function diploma_new_image(){
    $upload_dir   = wp_upload_dir();
    $rImg = ImageCreateFromJPEG($_POST['data']['image_path']);
    $cor = imagecolorallocate($rImg, 255, 255, 255);    

imagestring($rImg,50,150,550,urldecode(strtoupper($_POST['data']'filename'])),$cor);
header('Content-type: image/jpeg');
imagejpeg($rImg, $upload_dir['basedir']."/diploma_new/".str_replace(' ', '_', $_POST['data']['filename']),100);
            $title = $_POST['data']['names'].'_diploma'.rand(1,90);
            $description ='[fusion_builder_container ][fusion_builder_row][fusion_builder_column][fusion_title]Diplomă în anticorupție[/fusion_title][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]
    <div><h4>Descarca diploma ta in anticoruptie.</h4></div>
    <div><img src="'.$upload_dir['baseurl'].'/diploma_new/'.str_replace(' ', '_', $_POST['data'].round(['filename'])).'" /></div>';  
            $cat='cat'; 
            $tags='tags';
            $post = array(  
                    'post_title'    => $title,      
                    'post_content'  => $description,    
                    'post_category' => $cat,
                    'tags_input'    => $tags,
                    'post_status'   => 'publish', 
                    'post_type'     => 'post',
                    'tax_input'     => array( 'category' => '98' )
                    );  
                    wp_insert_post($post); 



  };

add_action( 'wp_ajax_get_details_diploma', 'get_details_diploma' );
add_action( 'wp_ajax_nopriv_get_details_diploma', 'get_details_diploma' );

function get_details_diploma(){
 $sucess_message = "detail functions";
 global $wpdb;
 $query = $wpdb->get_results("SELECT * FROM `wp_posts` ORDER BY id DESC limit 1 ");
 $url =  get_permalink($query[0]->ID);
 echo $url;
 die();
};

我不确定它在哪里中断,如果我在开发工具的源面板中查看,我可以在图像上看到404,这意味着它不是生成的,或者没有保存的,或者两者都不存在。您有解决这个挑战的想法吗?

source view for the diploma file

0 个答案:

没有答案