Skip to content
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

Add option to hide alt text #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hamza221
Copy link

adding the option of showing/hiding alt text from images

@hamza221 hamza221 changed the title add option to hide alt text Add option to hide alt text Mar 16, 2023
@ksidibe
Copy link

ksidibe commented Mar 19, 2023

This is a great addition. This is particularly useful for a multi language app like mine where the alt text display text in languages that are not that of the user.

@hamza221
Copy link
Author

hamza221 commented Apr 3, 2023

@mtibben really sorry for the disturbance, but any idea on when can this get a review 😀, Would really appreciate it, if you can give it a look.

@ChristophWurst
Copy link

@mtibben friendly ping. Would you be okay with this change?

@hamza221 hamza221 mentioned this pull request Aug 18, 2023
3 tasks
Copy link
Collaborator

@andrewnicols andrewnicols left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I do not agree with the direction of this change, but given it's behind a feature flag I think it's probably fine.

src/Html2Text.php Outdated Show resolved Hide resolved
src/Html2Text.php Outdated Show resolved Hide resolved
src/Html2Text.php Outdated Show resolved Hide resolved
test/ImageTest.php Outdated Show resolved Hide resolved
test/ImageTest.php Outdated Show resolved Hide resolved
src/Html2Text.php Outdated Show resolved Hide resolved
* show/hide alt text for images
*/

protected function convertImages(){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poor method naming. This does not actually convert images.
I'd suggest the same approach as convertBlockquotes and covnertPrewhere they take the value and actually perform the conversion. This will need to be done immediately after the current preg_replace to ensure b/c.

src/Html2Text.php Outdated Show resolved Hide resolved
@nick322
Copy link

nick322 commented Oct 2, 2024

If you have this problem, you can replace it first while waiting for an updated version:

$content = str_replace('alt=', 'alta=', $content); 
$content = str_replace('href=', 'hrefa=', $content);
$html = new Html2Text($content );
$html->getText();

@hamza221
Copy link
Author

hamza221 commented Oct 2, 2024

If you have this problem, you can replace it first while waiting for an updated version:

$content = str_replace('alt=', 'alta=', $content); 
$content = str_replace('href=', 'hrefa=', $content);
$html = new Html2Text($content );
$html->getText();

we switched to a forked version https://github.com/hamza221/html2text in the meantime, but it would be great to switch back to the original package

@nick322
Copy link

nick322 commented Oct 7, 2024

@andrewnicols Please review the code. 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.

5 participants