Skip to content

Enhanced Post.FirstImgSrc method to really find the first image #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 2, 2021

Conversation

jmalarcon
Copy link
Contributor

Hi:

I've just changed the Post.FirstImgSrc method's code to really find the first image in the post content using regular expressions.

The current code didn't find images with styles or other attributes, and that was a problem since a lot of people include images with different styles or alignments such as:

<img style="float:right;margin-left:1em;" src="whatever.png">

The current method only finds images that start exactly with:

<img src=

My change is 100% compatible with the previous but uses regular expressions to really find the first image in the post contents.

Bumped minor version to reflect change.

Thanks!

…e content using regular expressions.

The previous code didn't find images with styls or other attributes and that was a problem.
Bumped minor version to reflect change.
@rswilley
Copy link

rswilley commented Dec 11, 2017

I think this project has low activity now, but this helped me! Thanks

@jmalarcon
Copy link
Contributor Author

Thanks. Happy to help.

It's a pity that a lot of projects in the .NET world, used by thousands of people, get abandoned 😞

@farzindev
Copy link
Member

There is a conflict since this is way old.
But, because many themes don't have that default image (images/defaultImg.jpg), it's not a good idea to get it from the themes.

The best solution to this is to let the admin upload it from the settings. which will be the default post cover. But again, what if the theme doesn't support the cover.

But for now, I think the best default image would be a "data:image/svg+xml" like below that shows the Blog Title in the center of the image:

data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 700 300' width='700' height='300'%3E%3Crect width='700' height='300' fill='%23000000'%3E%3C/rect%3E%3Ctext x='50%' y='53%' dominant-baseline='middle' text-anchor='middle' font-family='Arial, sans-serif' font-size='30px' fill='%23ffffff'%3EBlog Title%3C/text%3E%3C/svg%3E

Anyways,
We are working on a new project similar to BlogEngine, please check it out:
https://github.com/blogifierdotnet/Blogifier


I'm closing this, If you wish to make the changes, please open this with the updates.

@farzindev farzindev closed this Apr 2, 2021
@jmalarcon
Copy link
Contributor Author

Hi:

I was just rewriting an already existing method to make it a little better. The problem with the conflict is that my PR is more than 3 years old, and the first response by a maintainer is just now 😒

If there's no image there's no problem at all (the same way that wasn't a problem before). It's just a better regular expression, that's it.

I agree on BlogEngine not being the best option to create a blog today with .NET, but if you have been using it for decades and have thousands of posts and comments (like myself), maybe you don't have a good chance to do a proper migration. My other blog, smaller, it's already migrated to a different system log ago. My main blog, unfortunately, it's not as easy to migrate without loosing a lot of info or without glitch.

Cheers!

@farzindev farzindev reopened this Apr 2, 2021
@farzindev farzindev merged commit 11b9f17 into BlogEngine:master Apr 2, 2021
@farzindev
Copy link
Member

Jose,
I'm sorry, but maintaining an open-source project, without contributions, is not an easy task.

Blogifier is under development. But already, you can import RSS. and all of your posts, files, categories will be imported.
We have plans to make it easier to migrate from BlogEngine to Blogifier. hopefully soon.

@jmalarcon
Copy link
Contributor Author

Hi @farzindev

Don't worry, I totally feel you, as I'm maintaining some projects by myself too (less popular, of course). But sometimes written communication can be misleading and one can sound harsh. Sorry about that.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants