Add an image field to the publication form (OJS 3.4)

I need to add an image field to the publication form, but I can’t get it to upload correctly. This is what I have so far. Can anyone help me?

<?php
import('lib.pkp.classes.plugins.ThemePlugin');

use APP\issue\Collector;
use APP\facades\Repo;

class ExampleThemePlugin extends ThemePlugin
{
	public function init()
	{
		(...)

		HookRegistry::register('TemplateManager::display', array($this, 'loadCurrentUrl'));
		HookRegistry::register('TemplateManager::display', array($this, 'loadCCLicenseBadge'));
		HookRegistry::register('TemplateManager::display', array($this, 'loadTemplateData'));
		HookRegistry::register('TemplateManager::display', array($this, 'loadKeywords'));
		HookRegistry::register('TemplateManager::display', array($this, 'articleMetrics'));
		HookRegistry::register('TemplateManager::display', array($this, 'loadMetrics'));
		HookRegistry::register('Schema::get::publication', array($this, 'addToPublicationSchema'));
		HookRegistry::register('Form::config::before', array($this, 'addToPublicationForm'));
		HookRegistry::register('LoadHandler', array($this, 'setPageHandler'));
	}

	

	public function addToPublicationForm($hookName, $form)
	{
		$request = Application::get()->getRequest();
		$context = $request->getContext();

		if (!$context || !defined('FORM_TITLE_ABSTRACT') || $form->id !== FORM_TITLE_ABSTRACT) {
			return;
		}

		$dispatcher = $request->getDispatcher();
		$publicFileManager = new PublicFileManager();
		$baseUrl = $request->getBaseUrl() . '/' . $publicFileManager->getContextFilesPath($context->getId());
		$temporaryFileApiUrl = $dispatcher->url($request, Application::ROUTE_API, $context->getPath(), 'temporaryFiles');


		$form->addField(new \PKP\components\forms\FieldUploadImage('publicationImage', [
			'label' => 'Imagen de la publicación',
			'description' => 'Suba una imagen representativa para esta publicación.',
			'groupId' => 'publishing',
			'value' => $form->publication->getData('publicationImage'),
			'baseUrl' => $baseUrl,

			'options' => [
				'url' => $temporaryFileApiUrl,
			],
		]));



	}
	public function addToPublicationSchema($hookName, $args)
	{
		$schema = $args[0];


		$schema->properties->publicationImage = (object) [
			'type' => 'object',
			'apiSummary' => true,
			'validation' => ['nullable'],
		];

		return false;
	}
	
	(..)

}

Thanks in advance.

Not sure what you are trying to achieve.
If it’s a graphical abstract, you could install the TextEditorExtras plugin and enable images for abstracts.
If it’s part of the galley, you can upload via galley. There is even an option to add an image caption, copyright owner, and more.