Can you use the company image which is already part of the form? That one’s stored in post meta.
Thread Starter
JS
(@jsbls)
No… since I’d like for the organizations using the service to upload their logo. I succesfully added another field and displayed it by adding another custom file field. My question now is if there is any way to limit the size or dimensions of the uploaded image (just like wordpress image upload does).
Great plugin by the way!
The size is limited to that of your allowed upload limit (usually 8mb).
I don’t think you can restrict the ‘actual’ size of the image though, and I don’t think WP does either. WP does however generate image sizes based on your settings – since this plugin just stores the URL in the meta data it doesn’t bother with that.
Thread Starter
JS
(@jsbls)
Ok, I can work with that. Thank you very much!
Here is the code I used to add an image to each listing if it’s any help for anybody. Add to your theme’s functions.php file.
/* Add image to listing */
add_filter( 'submit_job_form_fields', 'frontend_add_featured_image' );
function frontend_add_featured_image( $fields ) {
$fields['job']['job_image'] = array(
'label' => __( 'Image', 'job_manager' ),
'type' => 'file',
'required' => true,
'placeholder' => '',
'priority' => 7
);
return $fields;
}
/* Save input */
add_action( 'job_manager_update_job_data', 'frontend_add_featured_image_save', 10, 2 );
function frontend_add_featured_image_save( $job_id, $values ) {
update_post_meta( $job_id, '_job_image', $values['job']['job_image'] );
}
/* Add Custom Field to WP Admin Section */
add_filter( 'job_manager_job_listing_data_fields', 'admin_add_job_image_field' );
function admin_add_job_image_field( $fields ) {
$fields['_job_image'] = array(
'label' => __( 'Image', 'job_manager' ),
'type' => 'file',
'placeholder' => '',
'description' => ''
);
return $fields;
}
And then just add this wherever you want to display the image:
<img src="<?php echo $post->_job_image; ?>" alt="">