kayue / KayueWordpressBundle

A Symfony 2 bundle for providing WordPress repositories and authenticating users (login).
101 stars 43 forks source link

Add wp_get_attachment_alt_text function to get image alt text #83

Closed pmpr closed 6 years ago

pmpr commented 6 years ago

Add a twig function to get image alt text from _wp_attachment_image_alt post meta key.

pmpr commented 6 years ago

Tried to log the exception and return an empty string in case of possibel exception thrown during fundOneBy

kayue commented 6 years ago

Logging exception to log isn't a common practice in this bundle, but thanks anyway.

kayue commented 6 years ago

@peyman-mohamadpour Actually could you remove the logging part? Just return null if meta is not found.

Because no meta found doesn't has to be an exception. It is one of the expected result. In fact if you use Doctrine's getOneOrNullResult() instead of findOneBy() method, you won't even get this exception at all.

kayue commented 6 years ago

@peyman-mohamadpour And if logging is indeed needed in your project, you can still do it by checking null.

if (wp_get_attachment_alt_text() == null) { $loggin->log('Error!'); }
pmpr commented 6 years ago

Removed the logging part, created another pull request. Would be thankful if you could merge this into the upstream. Regards