Plugin for Uploading an Image to the Server

Post Reply
woods
Ssr. Bludit
Posts: 10
Joined: Mon May 25, 2020 9:56 pm

Hello,

at the Moment iam trying to creat a Plugin, that can save text and imagefiles to display them on my homepage. The Reason is, that i have a Homepage with different sections and a fixed css, where i just want to change the content without touching the html/php (so i client could change the text).

Actual i am able to change the text and i can change a image by storing an url to an image, but i would like to upload an image via a plugin.

Is there already a solution for this or a existing plugin, where i could copy some code?

thanks in advance.

my Plugin looks like this at the moment:

<?php

class pluginStartseite extends Plugin {

public function init()
{
$this->dbFields = array(
'text'=>'',
'text2'=>'',
'image'=>''
);
}

public function form()
{
$html = '<div class="alert alert-primary" role="alert">';
$html .= '<br><b>Here you can Change the Text for the Homepage</b><br><br>';
$html .= '</div>';

$html .= '<div>';
$html .= '<label>Change the Heading inside the Hero-Section</label>';
$html .= '<textarea name="text" id="jstext">'.$this->getValue('text').'</textarea>';
$html .= '</div>';

$html .= '<div>';
$html .= '<label>Change the Text inside the Hero-Section</label>';
$html .= '<textarea name="text2" id="jstext">'.$this->getValue('text2').'</textarea>';
$html .= '</div>';

$html .= '<div style="padding-top:30px">';
$html .= '<img width="300px" height="auto" src="'.$this->getValue('image').'"/>';
$html .= '</div>';

$html .= '<div>';
$html .= '<label>Link zu deinem Bild</label>';
$html .= '<textarea name="image" id="jstext">'.$this->getValue('image').'</textarea>';
$html .= '</div>';

$html .= '<div style="padding-bottom:100px">';
$html .= '</div>';

return $html;
}

}
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

There is all already there: editor, custom fields, image upload (or you can use for uploading the plugin Media or Media+).

Also you can use cover images, and the field description, if you do not use it for SEO (see theme Massively).
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
woods
Ssr. Bludit
Posts: 10
Joined: Mon May 25, 2020 9:56 pm

Thanks for your reply.

I think the media Plugin is the way to go for me.
it would be perfect for me to upload the picture directly in my plugin gui, but at least i can use the workaround to upload the image with the media plugin, copy the image-url and paste the url in my plugin.

i also tooked a look on the massivly theme, that also could be be a possible solution by using the description field and coverimage, but for me the plugin is a better way to edit all the different fields at one place.

maybe the costumfields could work great, but it would be better to display the costum field only for a specific page (for example only for the static page "home").
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

woods wrote: Tue May 26, 2020 10:24 am maybe the costumfields could work great, but it would be better to display the costum field only for a specific page (for example only for the static page "home").
No problem in the theme with an if condition.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
woods
Ssr. Bludit
Posts: 10
Joined: Mon May 25, 2020 9:56 pm

Thats true for the output on my php page.
I was talking about the Page "+content", where the costum fields can be filled.
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

woods wrote: Tue May 26, 2020 2:15 pm I was talking about the Page "+content", where the costum fields can be filled.
I cannot follow you... What is the page "+content"?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
woods
Ssr. Bludit
Posts: 10
Joined: Mon May 25, 2020 9:56 pm

I am talking about the Menu-Point in the Backend to creat a new page/post
"+ new content" (i am not using the english language, maybe the button is called different.
[in der deutschen version "+ neuer inhalt"]).

the costum field is alway showing up, no matter witch page you want to edit.
Post Reply