Of the two option you proposed, the latter is better for maintainability.
The reason is, if you ever need to move the site to another server or use the theme on another site, it seems an easier process to move / reuse.
If you’re not using the image for themeing, consider just using media library for post/page embeds.
Instead of:
bloginfo('template_directory');
Consider:
get_template_directory_uri();
or
get_stylesheet_directory_uri();
Source: https://developer.wordpress.org/reference/functions/bloginfo/#possible-values-for-show
Related Posts:
- How do I edit the php/html for a particular post?
- Can WP plugins access files outside the installation folder?
- How to replace file_get_contents() with a WordPress Filesystem call
- How to edit php code in WordPress Post file?
- Running rmdir function on post save
- Does WordPress create a new Linux user when creating a new WordPress blog?
- Adding regular php file to site
- Custom query to get post names beginning with a digit
- Custom Yoast Breadcrumbs URL
- Real time Duplicate title check
- How to check from which page the user is coming to the current page?
- Insert code when users come from an specific referer
- Adjust the results quantity for Search Results page pagination
- CSS saved & enqueued, but wordpress doesn’t load css text, only file
- Execute only on a certain page
- Audio tags around Mp3 URL in content
- Add a Custom Class to Admin Menus
- Type hinting and void return question
- Replace comment avatars and links at the same time
- How to display recent posts on home page with custom HTML
- Display user role Name – not slug
- How do I add text in a shortcode?
- How to display php source code inside a post using visual editor?
- Stumped – Ajax Response Returns 0
- Upload Image in a WordPress page using PHP
- Get Custom URL For Custom Taxonomy
- How to add custom post meta to default blog post?
- Shortcode content filter?
- Show full posts in archive
- I want to select the from values from database in WordPress? [closed]
- Error in custom php function doesn’t exist
- Paypal form integration with wordpress registration form without plugin [closed]
- Uploading files using the Settings API
- How can I hide that I Use WordPress (with W3 Total Cache)
- Can anyone offer any help with this function?
- JQuery calling a Custom PHP function (Works in Dev but not in WordPress)
- Changing the_posts_navigation() html output
- height should be set to auto to avoid pixelation in the post thumbnail function
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- Hide a div when tags doesnt exist [duplicate]
- Multiple meta_key in one global $wpdb;
- What does -> mean in WordPress?
- Parsing Menu Items and Blog Posts
- First Byte Time (back-end processing)
- How to update and save user metadata on page visits?
- How to optimize update_post_meta?
- Contact Form 7 – Replace database configured form template with a static file
- ACF & Bootstrap Gallery Shows Blank Slides [closed]
- Generate CSV file and add data as a new wordpress custom post
- child parent styles enqueue order
- Trying To Get Child Categories To Show, Issue With foreach Loop
- Add URL parameter to all internal links using a specific theme
- Call featured image url
- Use an anchor link to open an iframe inside a WordPress page
- How to make changes to style.php [closed]
- select wordpress custom post type
- In WordPress, how do you make several different editors for a single page?
- WordPress 6.0 class-wp-widget.php fatal errors in PHP 8.1.6
- Unserialize Custom Field & Save as Multiple Rows in WordPress Database
- Modify WooCommerce used to get all orders in dashboard
- Add a product category to a specific product via a button
- WordPress can’t use ZipArchive
- Add class to image in php
- Creating a checklist with ACF and I cannot figure out how to add all iterations to an array that I’m creating
- Trying to generate a CSS file in wordpress uploads folder
- register_setting not save checkbox
- How does one make a URL return dynamic JSON with custom Content Type?
- custom-header not working
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- Add Product Permalink in woocommerce admin order page
- Proper use of Output Buffer for a whole php clas
- How do I make comment-reply-button with that takes to comment reply form on click
- Allow user to choose header style
- Require advice handling a URL redirect from a Third Party. URL Params need to populate and then forward to payment
- missing admin bar and widget in a template
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- My own theme’s custom widget areas are not working
- Not able to add new item in wordpress home page
- How to apply filter
- Allow BBPress participant role to trash topics
- views How to load javascript on custom page template?
- How to find the function which is outputting Array
- Contact form field in wordpress menu
- Manipulate database of WordPress site with my own scripts
- How can I include a file related to blog URL? Nothing seems to work
- How Can I Center the Logo in the Navigation Menu? [closed]
- Where are Sessions are being started? [closed]
- Get the current page in a call back function
- PHP Use Declared array Variable inside already Declared Array
- How to create and add js and css file when server is not on my PC?
- Object of class WP_Post could not be converted to string while trying to console.log wp_get_nav_menu_items
- Check radio get value to array
- Your PHP installation appears to be missing the MySQL … After deleting and restarting from cpanel
- How to create shortcode of this PHP code
- Too few arguments to function woocommerce_update_product_acf_save_post()
- WordPress Query -> Ajax Query
- Can WordPress support Website (19GB database) Should I move Our WordPress Website to a custom one using Laravel or any other PHP framework?
- WordPress Importer Call to undefined function set_time_limit()
- Display terms on product page with shotrcode
- How to build a dropdown with tags for same post type?