wardrobecms / core-archived

Wardrobe Core Files

Home Page:http://wardrobecms.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[question] post image

dcrystalj opened this issue · comments

I can see there is image in migration. But there is nothing in public function create(array $data).
Are there any plans to implement this? Or should I do it?

You can drag and drop images into the text area of a blog post. It just adds them inline. —
Eric Barnes

On Sat, Feb 8, 2014 at 8:43 AM, Tomaz notifications@github.com wrote:

I can see there is image in migration. But there is nothing in public function create(array $data).

Are there any plans to implement this? Or should I do it?

Reply to this email directly or view it on GitHub:
#84

i need one picture for every blog post which is accessible when i'm listing posts like this:
http://laravel.io/forum

As you can see each post has independent "profile" picture from post content

Are you talking about the author image? You should be able to use gravatar with the existing setup. Otherwise it would have to be some custom changes.

No. Imagine blog like news page. When you list posts you display short text about post and one image (this image i want). When you click on that post you see full post with other images like in wardrobe. Do you understand?

Right now, this is not currently implemented and unfortunately, the CMS is all in or all out at this moment...

sorry but what does it mean "the CMS is all in or all out at this moment" :D ?

Even though the rewrite was made to make Wardrobe configurable, you still have to use all of its functionality at once. This also makes swapping out components in Wardrobe nearly impossible without some heavy copy-paste.

So, you either take all of its features as is… Or you essentially roll your own CMS from scratch.

I'm not sure I even understand what you are trying to do. When I go to http://laravel.io/forum all I see is a gravatar icon and then the title. Each post in wardrobe has an author and you could just use their email to display the gravatar.

I think that Laravel.io was a bad example, as @ericbarnes says, the forms do not use a user uploaded picture (the old ones may have). Instead, it just uses an author image from using the gravatar url based on their email.

To make a custom image placeholder for each post, it would require some hacking on a lot of the core functionality. Just to start would be the database schema and the model. The more important and awkward change would be how to modify the admin panel to account for the new inputs needed for this functionality.

I ran into a similar issue and found potential workaround. I didn't want to make a bunch of changes to the core so I wrote a helper function that takes the post content as input and returns the first image in the post. This means the first image is always the 'featured image' that people see, so it might not fit all use cases but it's better than nothing:

function get_first_image($content){
    preg_match('/<img.+src=[\'"](?P<src>.+)[\'"].*>/i', $content, $image);
    if(empty($image)){
        return null;
    }
    else{
        return $image[0];
    }
}

Now in your wardrobe archive or index view just add {{ get_first_image($post->parsed_content) }} where you want the image to appear. Preg_match isn't really that readable imho, so you could also implement https://packagist.org/packages/electrolinux/phpquery if thats a concern.

@natpoint Cool workaround. Just an FYI I'm adding the ability for a featured post image in v2.